@@ -56,45 +56,45 @@ discard block |
||
56 | 56 | const ERROR_PLACEHOLDER_NOT_FOUND = 47804; |
57 | 57 | const ERROR_INVALID_DELIMITER = 47805; |
58 | 58 | |
59 | - /** |
|
60 | - * @var Mailcode_Parser |
|
61 | - */ |
|
59 | + /** |
|
60 | + * @var Mailcode_Parser |
|
61 | + */ |
|
62 | 62 | protected $parser; |
63 | 63 | |
64 | - /** |
|
65 | - * @var Mailcode_Collection |
|
66 | - */ |
|
64 | + /** |
|
65 | + * @var Mailcode_Collection |
|
66 | + */ |
|
67 | 67 | protected $commands; |
68 | 68 | |
69 | - /** |
|
70 | - * @var string |
|
71 | - */ |
|
69 | + /** |
|
70 | + * @var string |
|
71 | + */ |
|
72 | 72 | protected $originalString; |
73 | 73 | |
74 | - /** |
|
75 | - * @var Mailcode_Collection |
|
76 | - */ |
|
74 | + /** |
|
75 | + * @var Mailcode_Collection |
|
76 | + */ |
|
77 | 77 | protected $collection; |
78 | 78 | |
79 | - /** |
|
80 | - * Counter for the placeholders, global for all placeholders. |
|
81 | - * @var integer |
|
82 | - */ |
|
79 | + /** |
|
80 | + * Counter for the placeholders, global for all placeholders. |
|
81 | + * @var integer |
|
82 | + */ |
|
83 | 83 | private static $counter = 0; |
84 | 84 | |
85 | - /** |
|
86 | - * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
87 | - */ |
|
85 | + /** |
|
86 | + * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
87 | + */ |
|
88 | 88 | protected $placeholders; |
89 | 89 | |
90 | - /** |
|
91 | - * @var string |
|
92 | - */ |
|
90 | + /** |
|
91 | + * @var string |
|
92 | + */ |
|
93 | 93 | protected $delimiter = '__'; |
94 | 94 | |
95 | - /** |
|
96 | - * @var string[]|NULL |
|
97 | - */ |
|
95 | + /** |
|
96 | + * @var string[]|NULL |
|
97 | + */ |
|
98 | 98 | protected $placeholderStrings; |
99 | 99 | |
100 | 100 | public function __construct(Mailcode_Parser $parser, string $subject) |
@@ -113,29 +113,29 @@ discard block |
||
113 | 113 | self::$counter = 0; |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves the string the safeguard was created for. |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
116 | + /** |
|
117 | + * Retrieves the string the safeguard was created for. |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | 121 | public function getOriginalString() : string |
122 | 122 | { |
123 | 123 | return $this->originalString; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * Sets the delimiter character sequence used to prepend |
|
128 | - * and append to the placeholders. |
|
129 | - * |
|
130 | - * The delimiter's default is "__" (two underscores). |
|
131 | - * |
|
132 | - * Minimum characters: 2 |
|
133 | - * Invalid characters: * |
|
134 | - * Rules: May not end or begin with a number |
|
135 | - * |
|
136 | - * @param string $delimiter |
|
137 | - * @return Mailcode_Parser_Safeguard |
|
138 | - */ |
|
126 | + /** |
|
127 | + * Sets the delimiter character sequence used to prepend |
|
128 | + * and append to the placeholders. |
|
129 | + * |
|
130 | + * The delimiter's default is "__" (two underscores). |
|
131 | + * |
|
132 | + * Minimum characters: 2 |
|
133 | + * Invalid characters: * |
|
134 | + * Rules: May not end or begin with a number |
|
135 | + * |
|
136 | + * @param string $delimiter |
|
137 | + * @return Mailcode_Parser_Safeguard |
|
138 | + */ |
|
139 | 139 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
140 | 140 | { |
141 | 141 | if(empty($delimiter)) |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | return $this->delimiter; |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Retrieves the safe string in which all commands have been replaced |
|
180 | - * by placeholder strings. |
|
181 | - * |
|
182 | - * @return string |
|
183 | - * @throws Mailcode_Exception |
|
184 | - * |
|
185 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
186 | - */ |
|
178 | + /** |
|
179 | + * Retrieves the safe string in which all commands have been replaced |
|
180 | + * by placeholder strings. |
|
181 | + * |
|
182 | + * @return string |
|
183 | + * @throws Mailcode_Exception |
|
184 | + * |
|
185 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
186 | + */ |
|
187 | 187 | public function makeSafe() : string |
188 | 188 | { |
189 | 189 | $this->requireValidCollection(); |
@@ -191,16 +191,16 @@ discard block |
||
191 | 191 | return $this->makeSafePartial(); |
192 | 192 | } |
193 | 193 | |
194 | - /** |
|
195 | - * Like makeSafe(), but allows partial (invalid) commands: use this |
|
196 | - * if the subject string may contain only part of the whole set of |
|
197 | - * commands. |
|
198 | - * |
|
199 | - * Example: parsing a text with an opening if statement, without the |
|
200 | - * matching end statement. |
|
201 | - * |
|
202 | - * @return string |
|
203 | - */ |
|
194 | + /** |
|
195 | + * Like makeSafe(), but allows partial (invalid) commands: use this |
|
196 | + * if the subject string may contain only part of the whole set of |
|
197 | + * commands. |
|
198 | + * |
|
199 | + * Example: parsing a text with an opening if statement, without the |
|
200 | + * matching end statement. |
|
201 | + * |
|
202 | + * @return string |
|
203 | + */ |
|
204 | 204 | public function makeSafePartial() : string |
205 | 205 | { |
206 | 206 | $placeholders = $this->getPlaceholders(); |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - /** |
|
314 | - * Creates a formatting handler, which can be used to specify |
|
315 | - * which formattings to use for the commands in the subject string. |
|
316 | - * |
|
317 | - * @param Mailcode_StringContainer|string $subject |
|
318 | - * @return Mailcode_Parser_Safeguard_Formatting |
|
319 | - */ |
|
313 | + /** |
|
314 | + * Creates a formatting handler, which can be used to specify |
|
315 | + * which formattings to use for the commands in the subject string. |
|
316 | + * |
|
317 | + * @param Mailcode_StringContainer|string $subject |
|
318 | + * @return Mailcode_Parser_Safeguard_Formatting |
|
319 | + */ |
|
320 | 320 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
321 | 321 | { |
322 | 322 | if(is_string($subject)) |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | return new Mailcode_Parser_Safeguard_Formatting($this, $subject); |
328 | 328 | } |
329 | 329 | |
330 | - /** |
|
331 | - * Retrieves all placeholders that have to be added to |
|
332 | - * the subject text. |
|
333 | - * |
|
334 | - * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
335 | - */ |
|
330 | + /** |
|
331 | + * Retrieves all placeholders that have to be added to |
|
332 | + * the subject text. |
|
333 | + * |
|
334 | + * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
335 | + */ |
|
336 | 336 | public function getPlaceholders() |
337 | 337 | { |
338 | 338 | if(isset($this->placeholders)) |
@@ -408,16 +408,16 @@ discard block |
||
408 | 408 | return $string; |
409 | 409 | } |
410 | 410 | |
411 | - /** |
|
412 | - * Makes the string whole again after transforming or filtering it, |
|
413 | - * by replacing the command placeholders with the original commands. |
|
414 | - * |
|
415 | - * @param string $string |
|
416 | - * @return string |
|
417 | - * @throws Mailcode_Exception |
|
418 | - * |
|
419 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
420 | - */ |
|
411 | + /** |
|
412 | + * Makes the string whole again after transforming or filtering it, |
|
413 | + * by replacing the command placeholders with the original commands. |
|
414 | + * |
|
415 | + * @param string $string |
|
416 | + * @return string |
|
417 | + * @throws Mailcode_Exception |
|
418 | + * |
|
419 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
420 | + */ |
|
421 | 421 | public function makeWhole(string $string) : string |
422 | 422 | { |
423 | 423 | return $this->restore( |
@@ -427,15 +427,15 @@ discard block |
||
427 | 427 | ); |
428 | 428 | } |
429 | 429 | |
430 | - /** |
|
431 | - * Like `makeWhole()`, but ignores missing command placeholders. |
|
432 | - * |
|
433 | - * @param string $string |
|
434 | - * @return string |
|
435 | - * @throws Mailcode_Exception |
|
436 | - * |
|
437 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
438 | - */ |
|
430 | + /** |
|
431 | + * Like `makeWhole()`, but ignores missing command placeholders. |
|
432 | + * |
|
433 | + * @param string $string |
|
434 | + * @return string |
|
435 | + * @throws Mailcode_Exception |
|
436 | + * |
|
437 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
438 | + */ |
|
439 | 439 | public function makeWholePartial(string $string) : string |
440 | 440 | { |
441 | 441 | return $this->restore( |
@@ -445,19 +445,19 @@ discard block |
||
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
448 | - /** |
|
449 | - * Like `makeWhole()`, but replaces the commands with a syntax |
|
450 | - * highlighted version, meant for human readable texts only. |
|
451 | - * |
|
452 | - * Note: the commands lose their functionality (They cannot be |
|
453 | - * parsed from that string again). |
|
454 | - * |
|
455 | - * @param string $string |
|
456 | - * @return string |
|
457 | - * @throws Mailcode_Exception |
|
458 | - * |
|
459 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
460 | - */ |
|
448 | + /** |
|
449 | + * Like `makeWhole()`, but replaces the commands with a syntax |
|
450 | + * highlighted version, meant for human readable texts only. |
|
451 | + * |
|
452 | + * Note: the commands lose their functionality (They cannot be |
|
453 | + * parsed from that string again). |
|
454 | + * |
|
455 | + * @param string $string |
|
456 | + * @return string |
|
457 | + * @throws Mailcode_Exception |
|
458 | + * |
|
459 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
460 | + */ |
|
461 | 461 | public function makeHighlighted(string $string) : string |
462 | 462 | { |
463 | 463 | return $this->restore( |
@@ -467,15 +467,15 @@ discard block |
||
467 | 467 | ); |
468 | 468 | } |
469 | 469 | |
470 | - /** |
|
471 | - * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
472 | - * |
|
473 | - * @param string $string |
|
474 | - * @return string |
|
475 | - * @throws Mailcode_Exception |
|
476 | - * |
|
477 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
478 | - */ |
|
470 | + /** |
|
471 | + * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
472 | + * |
|
473 | + * @param string $string |
|
474 | + * @return string |
|
475 | + * @throws Mailcode_Exception |
|
476 | + * |
|
477 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
478 | + */ |
|
479 | 479 | public function makeHighlightedPartial(string $string) : string |
480 | 480 | { |
481 | 481 | return $this->restore( |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | ); |
486 | 486 | } |
487 | 487 | |
488 | - /** |
|
489 | - * Retrieves the commands collection contained in the string. |
|
490 | - * |
|
491 | - * @return Mailcode_Collection |
|
492 | - */ |
|
488 | + /** |
|
489 | + * Retrieves the commands collection contained in the string. |
|
490 | + * |
|
491 | + * @return Mailcode_Collection |
|
492 | + */ |
|
493 | 493 | public function getCollection() : Mailcode_Collection |
494 | 494 | { |
495 | 495 | if(isset($this->collection)) |
@@ -507,11 +507,11 @@ discard block |
||
507 | 507 | return $this->getCollection()->isValid(); |
508 | 508 | } |
509 | 509 | |
510 | - /** |
|
511 | - * @throws Mailcode_Exception |
|
512 | - * |
|
513 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
514 | - */ |
|
510 | + /** |
|
511 | + * @throws Mailcode_Exception |
|
512 | + * |
|
513 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
514 | + */ |
|
515 | 515 | protected function requireValidCollection() : void |
516 | 516 | { |
517 | 517 | if($this->getCollection()->isValid()) |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | ); |
531 | 531 | } |
532 | 532 | |
533 | - /** |
|
534 | - * Retrieves a list of all placeholder IDs used in the text. |
|
535 | - * |
|
536 | - * @return string[] |
|
537 | - */ |
|
533 | + /** |
|
534 | + * Retrieves a list of all placeholder IDs used in the text. |
|
535 | + * |
|
536 | + * @return string[] |
|
537 | + */ |
|
538 | 538 | public function getPlaceholderStrings() : array |
539 | 539 | { |
540 | 540 | if(is_array($this->placeholderStrings)) |
@@ -561,13 +561,13 @@ discard block |
||
561 | 561 | return in_array($subject, $ids); |
562 | 562 | } |
563 | 563 | |
564 | - /** |
|
565 | - * Retrieves a placeholder instance by its ID. |
|
566 | - * |
|
567 | - * @param int $id |
|
568 | - * @throws Mailcode_Exception If the placeholder was not found. |
|
569 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
570 | - */ |
|
564 | + /** |
|
565 | + * Retrieves a placeholder instance by its ID. |
|
566 | + * |
|
567 | + * @param int $id |
|
568 | + * @throws Mailcode_Exception If the placeholder was not found. |
|
569 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
570 | + */ |
|
571 | 571 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
572 | 572 | { |
573 | 573 | $placeholders = $this->getPlaceholders(); |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | ); |
591 | 591 | } |
592 | 592 | |
593 | - /** |
|
594 | - * Retrieves a placeholder instance by its replacement text. |
|
595 | - * |
|
596 | - * @param string $string |
|
597 | - * @throws Mailcode_Exception |
|
598 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
599 | - */ |
|
593 | + /** |
|
594 | + * Retrieves a placeholder instance by its replacement text. |
|
595 | + * |
|
596 | + * @param string $string |
|
597 | + * @throws Mailcode_Exception |
|
598 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
599 | + */ |
|
600 | 600 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
601 | 601 | { |
602 | 602 | $placeholders = $this->getPlaceholders(); |