@@ -57,45 +57,45 @@ discard block |
||
57 | 57 | |
58 | 58 | const ERROR_PLACEHOLDER_NOT_FOUND = 47804; |
59 | 59 | |
60 | - /** |
|
61 | - * @var Mailcode_Parser |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var Mailcode_Parser |
|
62 | + */ |
|
63 | 63 | protected $parser; |
64 | 64 | |
65 | - /** |
|
66 | - * @var Mailcode_Collection |
|
67 | - */ |
|
65 | + /** |
|
66 | + * @var Mailcode_Collection |
|
67 | + */ |
|
68 | 68 | protected $commands; |
69 | 69 | |
70 | - /** |
|
71 | - * @var string |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var string |
|
72 | + */ |
|
73 | 73 | protected $originalString; |
74 | 74 | |
75 | - /** |
|
76 | - * @var Mailcode_Collection |
|
77 | - */ |
|
75 | + /** |
|
76 | + * @var Mailcode_Collection |
|
77 | + */ |
|
78 | 78 | protected $collection; |
79 | 79 | |
80 | - /** |
|
81 | - * Counter for the placeholders, global for all placeholders. |
|
82 | - * @var integer |
|
83 | - */ |
|
80 | + /** |
|
81 | + * Counter for the placeholders, global for all placeholders. |
|
82 | + * @var integer |
|
83 | + */ |
|
84 | 84 | private static $counter = 0; |
85 | 85 | |
86 | - /** |
|
87 | - * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
88 | - */ |
|
86 | + /** |
|
87 | + * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
88 | + */ |
|
89 | 89 | protected $placeholders; |
90 | 90 | |
91 | - /** |
|
92 | - * @var string |
|
93 | - */ |
|
91 | + /** |
|
92 | + * @var string |
|
93 | + */ |
|
94 | 94 | protected $delimiter = '__'; |
95 | 95 | |
96 | - /** |
|
97 | - * @var string[]|NULL |
|
98 | - */ |
|
96 | + /** |
|
97 | + * @var string[]|NULL |
|
98 | + */ |
|
99 | 99 | protected $placeholderStrings; |
100 | 100 | |
101 | 101 | public function __construct(Mailcode_Parser $parser, string $subject) |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | $this->originalString = $subject; |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Sets the delimiter character sequence used to prepend |
|
109 | - * and append to the placeholders. |
|
110 | - * |
|
111 | - * The delimiter's default is "__" (two underscores). |
|
112 | - * |
|
113 | - * @param string $delimiter |
|
114 | - * @return Mailcode_Parser_Safeguard |
|
115 | - */ |
|
107 | + /** |
|
108 | + * Sets the delimiter character sequence used to prepend |
|
109 | + * and append to the placeholders. |
|
110 | + * |
|
111 | + * The delimiter's default is "__" (two underscores). |
|
112 | + * |
|
113 | + * @param string $delimiter |
|
114 | + * @return Mailcode_Parser_Safeguard |
|
115 | + */ |
|
116 | 116 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
117 | 117 | { |
118 | 118 | if(empty($delimiter)) |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | return $this->delimiter; |
135 | 135 | } |
136 | 136 | |
137 | - /** |
|
138 | - * Retrieves the safe string in which all commands have been replaced |
|
139 | - * by placeholder strings. |
|
140 | - * |
|
141 | - * @return string |
|
142 | - * @throws Mailcode_Exception |
|
143 | - * |
|
144 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
145 | - */ |
|
137 | + /** |
|
138 | + * Retrieves the safe string in which all commands have been replaced |
|
139 | + * by placeholder strings. |
|
140 | + * |
|
141 | + * @return string |
|
142 | + * @throws Mailcode_Exception |
|
143 | + * |
|
144 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
145 | + */ |
|
146 | 146 | public function makeSafe() : string |
147 | 147 | { |
148 | 148 | $this->requireValidCollection(); |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | return str_replace(array_values($replaces), array_keys($replaces), $this->originalString); |
153 | 153 | } |
154 | 154 | |
155 | - /** |
|
156 | - * @param bool $highlighted |
|
157 | - * @return string[]string |
|
158 | - */ |
|
155 | + /** |
|
156 | + * @param bool $highlighted |
|
157 | + * @return string[]string |
|
158 | + */ |
|
159 | 159 | protected function getReplaces(bool $highlighted=false) : array |
160 | 160 | { |
161 | 161 | $placeholders = $this->getPlaceholders(); |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - /** |
|
186 | - * Retrieves all placeholders that have to be added to |
|
187 | - * the subject text. |
|
188 | - * |
|
189 | - * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
190 | - */ |
|
185 | + /** |
|
186 | + * Retrieves all placeholders that have to be added to |
|
187 | + * the subject text. |
|
188 | + * |
|
189 | + * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
190 | + */ |
|
191 | 191 | public function getPlaceholders() |
192 | 192 | { |
193 | 193 | if(isset($this->placeholders)) |
@@ -239,46 +239,46 @@ discard block |
||
239 | 239 | return str_replace($placeholderStrings, array_values($replaces), $string); |
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
243 | - * Makes the string whole again after transforming or filtering it, |
|
244 | - * by replacing the command placeholders with the original commands. |
|
245 | - * |
|
246 | - * @param string $string |
|
247 | - * @return string |
|
248 | - * @throws Mailcode_Exception |
|
249 | - * |
|
250 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
251 | - * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
252 | - */ |
|
242 | + /** |
|
243 | + * Makes the string whole again after transforming or filtering it, |
|
244 | + * by replacing the command placeholders with the original commands. |
|
245 | + * |
|
246 | + * @param string $string |
|
247 | + * @return string |
|
248 | + * @throws Mailcode_Exception |
|
249 | + * |
|
250 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
251 | + * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
252 | + */ |
|
253 | 253 | public function makeWhole(string $string) : string |
254 | 254 | { |
255 | 255 | return $this->restore($string, false); |
256 | 256 | } |
257 | 257 | |
258 | - /** |
|
259 | - * Like makeWhole(), but replaces the commands with a syntax |
|
260 | - * highlighted version, meant for human readable texts only. |
|
261 | - * |
|
262 | - * Note: the commands lose their functionality (They cannot be |
|
263 | - * parsed from that string again). |
|
264 | - * |
|
265 | - * @param string $string |
|
266 | - * @return string |
|
267 | - * @throws Mailcode_Exception |
|
268 | - * |
|
269 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
270 | - * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
271 | - */ |
|
258 | + /** |
|
259 | + * Like makeWhole(), but replaces the commands with a syntax |
|
260 | + * highlighted version, meant for human readable texts only. |
|
261 | + * |
|
262 | + * Note: the commands lose their functionality (They cannot be |
|
263 | + * parsed from that string again). |
|
264 | + * |
|
265 | + * @param string $string |
|
266 | + * @return string |
|
267 | + * @throws Mailcode_Exception |
|
268 | + * |
|
269 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
270 | + * @see Mailcode_Parser_Safeguard::ERROR_COMMAND_PLACEHOLDER_MISSING |
|
271 | + */ |
|
272 | 272 | public function makeHighlighted(string $string) : string |
273 | 273 | { |
274 | 274 | return $this->restore($string, true); |
275 | 275 | } |
276 | 276 | |
277 | - /** |
|
278 | - * Retrieves the commands collection contained in the string. |
|
279 | - * |
|
280 | - * @return Mailcode_Collection |
|
281 | - */ |
|
277 | + /** |
|
278 | + * Retrieves the commands collection contained in the string. |
|
279 | + * |
|
280 | + * @return Mailcode_Collection |
|
281 | + */ |
|
282 | 282 | public function getCollection() : Mailcode_Collection |
283 | 283 | { |
284 | 284 | if(isset($this->collection)) |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | return $this->getCollection()->isValid(); |
297 | 297 | } |
298 | 298 | |
299 | - /** |
|
300 | - * @throws Mailcode_Exception |
|
301 | - * |
|
302 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
303 | - */ |
|
299 | + /** |
|
300 | + * @throws Mailcode_Exception |
|
301 | + * |
|
302 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
303 | + */ |
|
304 | 304 | protected function requireValidCollection() : void |
305 | 305 | { |
306 | 306 | if($this->getCollection()->isValid()) |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | ); |
319 | 319 | } |
320 | 320 | |
321 | - /** |
|
322 | - * Retrieves a list of all placeholder IDs used in the text. |
|
323 | - * |
|
324 | - * @return string[] |
|
325 | - */ |
|
321 | + /** |
|
322 | + * Retrieves a list of all placeholder IDs used in the text. |
|
323 | + * |
|
324 | + * @return string[] |
|
325 | + */ |
|
326 | 326 | public function getPlaceholderStrings() : array |
327 | 327 | { |
328 | 328 | if(isset($this->placeholderStrings)) |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | return in_array($subject, $ids); |
350 | 350 | } |
351 | 351 | |
352 | - /** |
|
353 | - * Retrieves a placeholder instance by its ID. |
|
354 | - * |
|
355 | - * @param int $id |
|
356 | - * @throws Mailcode_Exception If the placeholder was not found. |
|
357 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
358 | - */ |
|
352 | + /** |
|
353 | + * Retrieves a placeholder instance by its ID. |
|
354 | + * |
|
355 | + * @param int $id |
|
356 | + * @throws Mailcode_Exception If the placeholder was not found. |
|
357 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
358 | + */ |
|
359 | 359 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
360 | 360 | { |
361 | 361 | $placeholders = $this->getPlaceholders(); |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | ); |
379 | 379 | } |
380 | 380 | |
381 | - /** |
|
382 | - * Retrieves a placeholder instance by its replacement text. |
|
383 | - * |
|
384 | - * @param string $string |
|
385 | - * @throws Mailcode_Exception |
|
386 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
387 | - */ |
|
381 | + /** |
|
382 | + * Retrieves a placeholder instance by its replacement text. |
|
383 | + * |
|
384 | + * @param string $string |
|
385 | + * @throws Mailcode_Exception |
|
386 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
387 | + */ |
|
388 | 388 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
389 | 389 | { |
390 | 390 | $placeholders = $this->getPlaceholders(); |