1 | <?php |
||
7 | class Render |
||
8 | { |
||
9 | /** |
||
10 | * Encoding to use if not provided |
||
11 | */ |
||
12 | const ENCODING_DEFAULT = 'UTF-8'; |
||
13 | |||
14 | /** |
||
15 | * Optional <head> elements |
||
16 | */ |
||
17 | const OPTIONAL_HEAD_ELEMENTS = [ |
||
18 | 'title', |
||
19 | 'dateCreated', |
||
20 | 'dateModified', |
||
21 | 'ownerName', |
||
22 | 'ownerEmail', |
||
23 | 'ownerId', |
||
24 | 'docs', |
||
25 | 'expansionState', |
||
26 | 'vertScrollState', |
||
27 | 'windowTop', |
||
28 | 'windowLeft', |
||
29 | 'windowBottom', |
||
30 | 'windowRight' |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * OPML versions supported |
||
35 | */ |
||
36 | const SUPPORTED_VERSIONS = [ |
||
37 | '2.0', |
||
38 | '1.0' |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * Default OPML version to use, if none is set |
||
43 | */ |
||
44 | const VERSION_DEFAULT = '2.0'; |
||
45 | |||
46 | /** |
||
47 | * Version to use for the build |
||
48 | * 2.0 - `text` attribute is required |
||
49 | * 1.0 - for legacy support |
||
50 | * @var bool |
||
51 | */ |
||
52 | protected $version; |
||
53 | |||
54 | /** |
||
55 | * Rendered XML object |
||
56 | * @var SimpleXMLElement |
||
57 | */ |
||
58 | protected $object; |
||
59 | |||
60 | /** |
||
61 | * Constructor |
||
62 | * |
||
63 | * @param array $array is the array we want to render and must follow structure defined above |
||
64 | * @param string $version '2.0' if `text` attribute is required, '1.0' for legacy |
||
65 | * @throws Exceptions\RenderException |
||
66 | */ |
||
67 | public function __construct($array, $version = self::VERSION_DEFAULT) |
||
95 | |||
96 | /** |
||
97 | * Create a XML outline object in a parent object. |
||
98 | * |
||
99 | * @param SimpleXMLElement $parent_elt is the parent object of current outline |
||
100 | * @param array $outline array representing an outline object |
||
101 | * @return void |
||
102 | * @throws Exceptions\RenderException |
||
103 | */ |
||
104 | protected function render_outline($parent_elt, $outline) |
||
129 | |||
130 | /** |
||
131 | * Return as a XML object |
||
132 | * |
||
133 | * @return SimpleXMLElement |
||
134 | */ |
||
135 | public function asXMLObject() |
||
139 | |||
140 | /** |
||
141 | * Return as an OPML string |
||
142 | * |
||
143 | * @param string $encoding Character encoding |
||
144 | * @return string |
||
145 | */ |
||
146 | public function asString($encoding = self::ENCODING_DEFAULT) |
||
154 | } |
||
155 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.