@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function getReplacementText() : string |
| 71 | 71 | { |
| 72 | - if(!empty($this->replacement)) |
|
| 72 | + if (!empty($this->replacement)) |
|
| 73 | 73 | { |
| 74 | 74 | return $this->replacement; |
| 75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | // to total amount of zeroes to pad with to obtain the total length |
| 88 | 88 | $padLength = $this->getLength() - $length - 1; // -1 for the ID separator char |
| 89 | 89 | |
| 90 | - if($padLength < 0) |
|
| 90 | + if ($padLength < 0) |
|
| 91 | 91 | { |
| 92 | 92 | $padLength = 0; |
| 93 | 93 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | // separator, there is no ambiguity. It becomes "1*000000000" and |
| 105 | 105 | // "10*00000000", keeping the ID intact. |
| 106 | 106 | |
| 107 | - $paddedID = str_pad((string)$this->id.'*', $padLength, '0'); |
|
| 107 | + $paddedID = str_pad((string)$this->id.'*', $padLength, '0'); |
|
| 108 | 108 | |
| 109 | 109 | $this->replacement = sprintf($format, $paddedID); |
| 110 | 110 | |
@@ -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(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
| 140 | 140 | { |
| 141 | - if(empty($delimiter)) |
|
| 141 | + if (empty($delimiter)) |
|
| 142 | 142 | { |
| 143 | 143 | throw new Mailcode_Exception( |
| 144 | 144 | 'Empty delimiter', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if(!preg_match('/\A[^0-9*].*[^0-9*]\z/x', $delimiter)) |
|
| 150 | + if (!preg_match('/\A[^0-9*].*[^0-9*]\z/x', $delimiter)) |
|
| 151 | 151 | { |
| 152 | 152 | throw new Mailcode_Exception( |
| 153 | 153 | 'The delimiter may not begin or end with a number.', |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if(strstr($delimiter, '*') !== false) |
|
| 159 | + if (strstr($delimiter, '*') !== false) |
|
| 160 | 160 | { |
| 161 | 161 | throw new Mailcode_Exception( |
| 162 | 162 | 'The delimiter may not contain the * character.', |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $placeholders = $this->getPlaceholders(); |
| 207 | 207 | $string = $this->originalString; |
| 208 | 208 | |
| 209 | - foreach($placeholders as $placeholder) |
|
| 209 | + foreach ($placeholders as $placeholder) |
|
| 210 | 210 | { |
| 211 | 211 | $string = $this->makePlaceholderSafe($string, $placeholder); |
| 212 | 212 | } |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | $placeholders = $this->getPlaceholders(); |
| 237 | 237 | $total = count($placeholders); |
| 238 | 238 | |
| 239 | - for($i=0; $i < $total; $i++) |
|
| 239 | + for ($i = 0; $i < $total; $i++) |
|
| 240 | 240 | { |
| 241 | 241 | $placeholder = $placeholders[$i]; |
| 242 | 242 | $command = $placeholder->getCommand(); |
| 243 | 243 | |
| 244 | - if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 244 | + if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 245 | 245 | { |
| 246 | - $string = $command->protectContent($string, $placeholder, $placeholders[$i+1]); |
|
| 246 | + $string = $command->protectContent($string, $placeholder, $placeholders[$i + 1]); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $pos = mb_strpos($string, $placeholder->getOriginalText()); |
| 256 | 256 | |
| 257 | - if($pos === false) |
|
| 257 | + if ($pos === false) |
|
| 258 | 258 | { |
| 259 | 259 | throw new Mailcode_Exception( |
| 260 | 260 | 'Placeholder original text not found', |
@@ -286,23 +286,23 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $placeholders = $this->getPlaceholders(); |
| 288 | 288 | |
| 289 | - foreach($urls as $url) |
|
| 289 | + foreach ($urls as $url) |
|
| 290 | 290 | { |
| 291 | - if(stristr($url, 'tel:')) |
|
| 291 | + if (stristr($url, 'tel:')) |
|
| 292 | 292 | { |
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - foreach($placeholders as $placeholder) |
|
| 296 | + foreach ($placeholders as $placeholder) |
|
| 297 | 297 | { |
| 298 | 298 | $command = $placeholder->getCommand(); |
| 299 | 299 | |
| 300 | - if(!$command->supportsURLEncoding()) |
|
| 300 | + if (!$command->supportsURLEncoding()) |
|
| 301 | 301 | { |
| 302 | 302 | continue; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if(strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded()) |
|
| 305 | + if (strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded()) |
|
| 306 | 306 | { |
| 307 | 307 | $command->setURLEncoding(true); |
| 308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
| 321 | 321 | { |
| 322 | - if(is_string($subject)) |
|
| 322 | + if (is_string($subject)) |
|
| 323 | 323 | { |
| 324 | 324 | $subject = Mailcode::create()->createString($subject); |
| 325 | 325 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function getPlaceholders() |
| 337 | 337 | { |
| 338 | - if(isset($this->placeholders)) |
|
| 338 | + if (isset($this->placeholders)) |
|
| 339 | 339 | { |
| 340 | 340 | return $this->placeholders; |
| 341 | 341 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | $cmds = $this->getCollection()->getCommands(); |
| 346 | 346 | |
| 347 | - foreach($cmds as $command) |
|
| 347 | + foreach ($cmds as $command) |
|
| 348 | 348 | { |
| 349 | 349 | self::$counter++; |
| 350 | 350 | |
@@ -365,21 +365,21 @@ discard block |
||
| 365 | 365 | * @return string |
| 366 | 366 | * @throws Mailcode_Exception |
| 367 | 367 | */ |
| 368 | - protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string |
|
| 368 | + protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string |
|
| 369 | 369 | { |
| 370 | - if(!$partial) |
|
| 370 | + if (!$partial) |
|
| 371 | 371 | { |
| 372 | 372 | $this->requireValidCollection(); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | $formatting = $this->createFormatting($string); |
| 376 | 376 | |
| 377 | - if($partial) |
|
| 377 | + if ($partial) |
|
| 378 | 378 | { |
| 379 | 379 | $formatting->makePartial(); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if($highlighted) |
|
| 382 | + if ($highlighted) |
|
| 383 | 383 | { |
| 384 | 384 | $formatting->replaceWithHTMLHighlighting(); |
| 385 | 385 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | { |
| 400 | 400 | $command = $placeholder->getCommand(); |
| 401 | 401 | |
| 402 | - if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 402 | + if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
| 403 | 403 | { |
| 404 | 404 | $string = $command->restoreContent($string); |
| 405 | 405 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | */ |
| 493 | 493 | public function getCollection() : Mailcode_Collection |
| 494 | 494 | { |
| 495 | - if(isset($this->collection)) |
|
| 495 | + if (isset($this->collection)) |
|
| 496 | 496 | { |
| 497 | 497 | return $this->collection; |
| 498 | 498 | } |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | protected function requireValidCollection() : void |
| 516 | 516 | { |
| 517 | - if($this->getCollection()->isValid()) |
|
| 517 | + if ($this->getCollection()->isValid()) |
|
| 518 | 518 | { |
| 519 | 519 | return; |
| 520 | 520 | } |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | */ |
| 538 | 538 | public function getPlaceholderStrings() : array |
| 539 | 539 | { |
| 540 | - if(is_array($this->placeholderStrings)) |
|
| 540 | + if (is_array($this->placeholderStrings)) |
|
| 541 | 541 | { |
| 542 | 542 | return $this->placeholderStrings; |
| 543 | 543 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | $this->placeholderStrings = array(); |
| 548 | 548 | |
| 549 | - foreach($placeholders as $placeholder) |
|
| 549 | + foreach ($placeholders as $placeholder) |
|
| 550 | 550 | { |
| 551 | 551 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
| 552 | 552 | } |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | { |
| 573 | 573 | $placeholders = $this->getPlaceholders(); |
| 574 | 574 | |
| 575 | - foreach($placeholders as $placeholder) |
|
| 575 | + foreach ($placeholders as $placeholder) |
|
| 576 | 576 | { |
| 577 | - if($placeholder->getID() === $id) |
|
| 577 | + if ($placeholder->getID() === $id) |
|
| 578 | 578 | { |
| 579 | 579 | return $placeholder; |
| 580 | 580 | } |
@@ -601,9 +601,9 @@ discard block |
||
| 601 | 601 | { |
| 602 | 602 | $placeholders = $this->getPlaceholders(); |
| 603 | 603 | |
| 604 | - foreach($placeholders as $placeholder) |
|
| 604 | + foreach ($placeholders as $placeholder) |
|
| 605 | 605 | { |
| 606 | - if($placeholder->getReplacementText() === $string) |
|
| 606 | + if ($placeholder->getReplacementText() === $string) |
|
| 607 | 607 | { |
| 608 | 608 | return $placeholder; |
| 609 | 609 | } |