1<?php
2
3namespace Sabre\Xml\Element;
4
5use Sabre\Xml;
6
7/**
8 * CDATA element.
9 *
10 * This element allows you to easily inject CDATA.
11 *
12 * Note that we strongly recommend avoiding CDATA nodes, unless you definitely
13 * know what you're doing, or you're working with unchangable systems that
14 * require CDATA.
15 *
16 * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
17 * @author Evert Pot (http://evertpot.com/)
18 * @license http://sabre.io/license/ Modified BSD License
19 */
20class Cdata implements Xml\XmlSerializable
21{
22    /**
23     * CDATA element value.
24     *
25     * @var string
26     */
27    protected $value;
28
29    /**
30     * Constructor
31     *
32     * @param string $value
33     */
34    function __construct($value)
35    {
36        $this->value = $value;
37    }
38
39    /**
40     * The xmlSerialize metod is called during xml writing.
41     *
42     * Use the $writer argument to write its own xml serialization.
43     *
44     * An important note: do _not_ create a parent element. Any element
45     * implementing XmlSerializble should only ever write what's considered
46     * its 'inner xml'.
47     *
48     * The parent of the current element is responsible for writing a
49     * containing element.
50     *
51     * This allows serializers to be re-used for different element names.
52     *
53     * If you are opening new elements, you must also close them again.
54     *
55     * @param Writer $writer
56     * @return void
57     */
58    function xmlSerialize(Xml\Writer $writer) {
59
60        $writer->writeCData($this->value);
61
62    }
63
64}
65