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) 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 * 46 * @return void 47 */ 48 function __construct($input = null, $options = 0) { 49 50 if (!is_null($input)) { 51 $this->setInput($input); 52 } 53 $this->options = $options; 54 } 55 56 /** 57 * This method starts the parsing process. 58 * 59 * If the input was not supplied during construction, it's possible to pass 60 * it here instead. 61 * 62 * If either input or options are not supplied, the defaults will be used. 63 * 64 * @param mixed $input 65 * @param int $options 66 * 67 * @return array 68 */ 69 abstract function parse($input = null, $options = 0); 70 71 /** 72 * Sets the input data. 73 * 74 * @param mixed $input 75 * 76 * @return void 77 */ 78 abstract function setInput($input); 79 80} 81