1<?php
2
3namespace Sabre\Xml\Element;
4
5use Sabre\Xml;
6
7class Mock implements Xml\Element {
8
9    /**
10     * The serialize method is called during xml writing.
11     *
12     * It should use the $writer argument to encode this object into XML.
13     *
14     * Important note: it is not needed to create the parent element. The
15     * parent element is already created, and we only have to worry about
16     * attributes, child elements and text (if any).
17     *
18     * Important note 2: If you are writing any new elements, you are also
19     * responsible for closing them.
20     *
21     * @param Xml\Writer $writer
22     * @return void
23     */
24    function xmlSerialize(Xml\Writer $writer) {
25
26        $writer->startElement('{http://sabredav.org/ns}elem1');
27        $writer->write('hiiii!');
28        $writer->endElement();
29
30    }
31
32    /**
33     * The deserialize method is called during xml parsing.
34     *
35     * This method is called statictly, this is because in theory this method
36     * may be used as a type of constructor, or factory method.
37     *
38     * Often you want to return an instance of the current class, but you are
39     * free to return other data as well.
40     *
41     * Important note 2: You are responsible for advancing the reader to the
42     * next element. Not doing anything will result in a never-ending loop.
43     *
44     * If you just want to skip parsing for this element altogether, you can
45     * just call $reader->next();
46     *
47     * $reader->parseSubTree() will parse the entire sub-tree, and advance to
48     * the next element.
49     *
50     * @param Xml\Reader $reader
51     * @return mixed
52     */
53    static function xmlDeserialize(Xml\Reader $reader) {
54
55        $reader->next();
56        return 'foobar';
57
58    }
59
60}
61