public function parse($input = null, $options = 0)
    {
        if (!is_null($input)) {
            $this->setInput($input);
        }
        if (is_null($this->input)) {
            throw new EofException('End of input stream, or no input supplied');
        }

        if (0 !== $options) {
            $this->options = $options;
        }

        switch ($this->input[0]) {
            case 'vcalendar':
                $this->root = new VCalendar([], false);
                break;
            case 'vcard':
                $this->root = new VCard([], false);
                break;
            default:
                throw new ParseException('The root component must either be a vcalendar, or a vcard');
        }
        foreach ($this->input[1] as $prop) {
            $this->root->add($this->parseProperty($prop));
        }
        if (isset($this->input[2])) {
            foreach ($this->input[2] as $comp) {
                $this->root->add($this->parseComponent($comp));
            }
        }

        // Resetting the input so we can throw an feof exception the next time.
        $this->input = null;

        return $this->root;
    }
public function parse($input = null, $options = 0)
    {
        if (!is_null($input)) {
            $this->setInput($input);
        }
        if (is_null($this->input)) {
            throw new EofException('End of input stream, or no input supplied');
        }

        if (0 !== $options) {
            $this->options = $options;
        }

        switch ($this->input[0]) {
            case 'vcalendar':
                $this->root = new VCalendar([], false);
                break;
            case 'vcard':
                $this->root = new VCard([], false);
                break;
            default:
                throw new ParseException('The root component must either be a vcalendar, or a vcard');
        }
        foreach ($this->input[1] as $prop) {
            $this->root->add($this->parseProperty($prop));
        }
        if (isset($this->input[2])) {
            foreach ($this->input[2] as $comp) {
                $this->root->add($this->parseComponent($comp));
            }
        }

        // Resetting the input so we can throw an feof exception the next time.
        $this->input = null;

        return $this->root;
    }
public function parse ( $ input = null , $ options = 0 ) { if ( ! is_null ( $ input ) ) { $ this -> setInput ( $ input ) ; } if ( is_null ( $ this -> input ) ) { throw new EofException ( 'End of input stream, or no input supplied' ) ; } if ( 0 !== $ options ) { $ this -> options = $ options ; } switch ( $ this -> input [ 0 ] ) { case 'vcalendar' : $ this -> root = new VCalendar ( [ ] , false ) ; break ; case 'vcard' : $ this -> root = new VCard ( [ ] , false ) ; break ; default : throw new ParseException ( 'The root component must either be a vcalendar, or a vcard' ) ; } foreach ( $ this -> input [ 1 ] as $ prop ) { $ this -> root -> add ( $ this -> parseProperty ( $ prop ) ) ; } if ( isset ( $ this -> input [ 2 ] ) ) { foreach ( $ this -> input [ 2 ] as $ comp ) { $ this -> root -> add ( $ this -> parseComponent ( $ comp ) ) ; } } // Resetting the input so we can throw an feof exception the next time. $ this -> input = null ; return $ this -> root ; }
This method starts the parsing process.

If the input was not supplied during construction, it's possible to pass
it here instead.

If either input or options are not supplied, the defaults will be used.

@param resource|string|array|null $input
@param int                        $options

@return \Sabre\VObject\Document
This method starts the parsing process .