1<?php 2 3namespace Sabre\VObject\Parser; 4 5/** 6 * Abstract parser. 7 * 8 * This class serves as a base-class for the different parsers. 9 * 10 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). 11 * @author Evert Pot (http://evertpot.com/) 12 * @license http://sabre.io/license/ Modified BSD License 13 */ 14abstract class Parser { 15 16 /** 17 * Turning on this option makes the parser more forgiving. 18 * 19 * In the case of the MimeDir parser, this means that the parser will 20 * accept slashes and underscores in property names, and it will also 21 * attempt to fix Microsoft vCard 2.1's broken line folding. 22 */ 23 const OPTION_FORGIVING = 1; 24 25 /** 26 * If this option is turned on, any lines we cannot parse will be ignored 27 * by the reader. 28 */ 29 const OPTION_IGNORE_INVALID_LINES = 2; 30 31 /** 32 * Bitmask of parser options 33 * 34 * @var int 35 */ 36 protected $options; 37 38 /** 39 * Creates the parser. 40 * 41 * Optionally, it's possible to parse the input stream here. 42 * 43 * @param mixed $input 44 * @param int $options Any parser options (OPTION constants). 45 * @return void 46 */ 47 public function __construct($input = null, $options = 0) { 48 49 if (!is_null($input)) { 50 $this->setInput($input); 51 } 52 $this->options = $options; 53 } 54 55 /** 56 * This method starts the parsing process. 57 * 58 * If the input was not supplied during construction, it's possible to pass 59 * it here instead. 60 * 61 * If either input or options are not supplied, the defaults will be used. 62 * 63 * @param mixed $input 64 * @param int|null $options 65 * @return array 66 */ 67 abstract public function parse($input = null, $options = null); 68 69 /** 70 * Sets the input data 71 * 72 * @param mixed $input 73 * @return void 74 */ 75 abstract public function setInput($input); 76 77} 78