1 | <?php |
||
26 | class ObjectWriter |
||
27 | { |
||
28 | /** |
||
29 | * @var SplFileObject |
||
30 | */ |
||
31 | private $fileObject; |
||
32 | |||
33 | /** |
||
34 | * @var bool |
||
35 | */ |
||
36 | private $requiresWhitespace = false; |
||
37 | |||
38 | /** |
||
39 | * @param SplFileObject $fileObject |
||
40 | */ |
||
41 | public function __construct(SplFileObject $fileObject) |
||
45 | |||
46 | /** |
||
47 | * Returns the current position in the file. |
||
48 | * |
||
49 | * @return int |
||
50 | */ |
||
51 | public function getCurrentOffset() |
||
55 | |||
56 | /** |
||
57 | * Writes a raw data line to the stream. |
||
58 | * |
||
59 | * A newline character is appended after the data. Keep in mind that you may still be after a token which requires |
||
60 | * a following whitespace, depending on the context you are in. |
||
61 | * |
||
62 | * @param string $data |
||
63 | */ |
||
64 | public function writeRawLine($data) |
||
68 | |||
69 | /** |
||
70 | * Starts a dictionary. |
||
71 | */ |
||
72 | public function startDictionary() |
||
77 | |||
78 | /** |
||
79 | * Ends a dictionary. |
||
80 | */ |
||
81 | public function endDictionary() |
||
86 | |||
87 | /** |
||
88 | * Starts an array. |
||
89 | */ |
||
90 | public function startArray() |
||
95 | |||
96 | /** |
||
97 | * Ends an array. |
||
98 | */ |
||
99 | public function endArray() |
||
104 | |||
105 | /** |
||
106 | * Writes a null value. |
||
107 | */ |
||
108 | public function writeNull() |
||
118 | |||
119 | /** |
||
120 | * Writes a boolean. |
||
121 | * |
||
122 | * @param bool $boolean |
||
123 | */ |
||
124 | public function writeBoolean($boolean) |
||
134 | |||
135 | /** |
||
136 | * Writes a number. |
||
137 | * |
||
138 | * @param int|float $number |
||
139 | * @throws InvalidArgumentException |
||
140 | */ |
||
141 | public function writeNumber($number) |
||
151 | |||
152 | /** |
||
153 | * Writes a name. |
||
154 | * |
||
155 | * @param string $name |
||
156 | */ |
||
157 | public function writeName($name) |
||
162 | |||
163 | /** |
||
164 | * Writes a literal string. |
||
165 | * |
||
166 | * The string itself is splitted into multiple lines after 248 characters. We chose that specific limit to avoid |
||
167 | * splitting mutli-byte characters in half. |
||
168 | * |
||
169 | * @param string $string |
||
170 | */ |
||
171 | public function writeLiteralString($string) |
||
176 | |||
177 | /** |
||
178 | * Writes a hexadecimal string. |
||
179 | * |
||
180 | * @param string $string |
||
181 | */ |
||
182 | public function writeHexadecimalString($string) |
||
187 | } |
||
188 |