@@ -30,19 +30,19 @@ |
||
30 | 30 | public const VALIDATION_UNCLOSED_COMMAND = 49104; |
31 | 31 | public const VALIDATION_CLOSING_NON_OPENING_COMMAND = 49105; |
32 | 32 | |
33 | - /** |
|
34 | - * @var Mailcode_Collection |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var Mailcode_Collection |
|
35 | + */ |
|
36 | 36 | protected $collection; |
37 | 37 | |
38 | - /** |
|
39 | - * @var OperationResult |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var OperationResult |
|
40 | + */ |
|
41 | 41 | protected $validationResult; |
42 | 42 | |
43 | - /** |
|
44 | - * @var Mailcode_Commands_Command_Type[] |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var Mailcode_Commands_Command_Type[] |
|
45 | + */ |
|
46 | 46 | protected $stack = array(); |
47 | 47 | |
48 | 48 | public function __construct(Mailcode_Collection $collection) |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | public const URL_ENCODING_DECODE = 'decode'; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var Mailcode_Factory_CommandSets |
|
32 | - */ |
|
31 | + * @var Mailcode_Factory_CommandSets |
|
32 | + */ |
|
33 | 33 | private static $commandSets; |
34 | 34 | |
35 | 35 | /** |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Creates a renderer instance, which can be used to easily |
|
87 | - * create and convert commands to strings. |
|
88 | - * |
|
89 | - * @return Mailcode_Renderer |
|
90 | - */ |
|
86 | + * Creates a renderer instance, which can be used to easily |
|
87 | + * create and convert commands to strings. |
|
88 | + * |
|
89 | + * @return Mailcode_Renderer |
|
90 | + */ |
|
91 | 91 | public static function createRenderer() : Mailcode_Renderer |
92 | 92 | { |
93 | 93 | return new Mailcode_Renderer(); |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Creates a printer instance, which works like the renderer, |
|
98 | - * but outputs the generated strings to standard output. |
|
99 | - * |
|
100 | - * @return Mailcode_Printer |
|
101 | - */ |
|
96 | + /** |
|
97 | + * Creates a printer instance, which works like the renderer, |
|
98 | + * but outputs the generated strings to standard output. |
|
99 | + * |
|
100 | + * @return Mailcode_Printer |
|
101 | + */ |
|
102 | 102 | public static function createPrinter() : Mailcode_Printer |
103 | 103 | { |
104 | 104 | return new Mailcode_Printer(); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Gets/creates the global instance of the date format info |
|
109 | - * class, used to handle date formatting aspects. |
|
110 | - * |
|
111 | - * @return Mailcode_Date_FormatInfo |
|
112 | - */ |
|
107 | + /** |
|
108 | + * Gets/creates the global instance of the date format info |
|
109 | + * class, used to handle date formatting aspects. |
|
110 | + * |
|
111 | + * @return Mailcode_Date_FormatInfo |
|
112 | + */ |
|
113 | 113 | public static function createDateInfo() : Mailcode_Date_FormatInfo |
114 | 114 | { |
115 | 115 | return Mailcode_Date_FormatInfo::getInstance(); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | $this->instantiator->checkCommand($cmd); |
35 | 35 | |
36 | - if($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
36 | + if ($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
37 | 37 | { |
38 | 38 | return $cmd; |
39 | 39 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | throw $this->instantiator->exceptionUnexpectedType('ShowVariable', $cmd); |
42 | 42 | } |
43 | 43 | |
44 | - public function date(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
44 | + public function date(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
45 | 45 | { |
46 | 46 | $variableName = $this->instantiator->filterVariableName($variableName); |
47 | 47 | |
48 | 48 | $format = ''; |
49 | - if(!empty($formatString)) |
|
49 | + if (!empty($formatString)) |
|
50 | 50 | { |
51 | 51 | $format = sprintf( |
52 | 52 | ' "%s"', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $this->instantiator->checkCommand($cmd); |
69 | 69 | |
70 | - if($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
70 | + if ($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
71 | 71 | { |
72 | 72 | return $cmd; |
73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | throw $this->instantiator->exceptionUnexpectedType('ShowDate', $cmd); |
76 | 76 | } |
77 | 77 | |
78 | - public function number(string $variableName, string $formatString="", bool $absolute=false) : Mailcode_Commands_Command_ShowNumber |
|
78 | + public function number(string $variableName, string $formatString = "", bool $absolute = false) : Mailcode_Commands_Command_ShowNumber |
|
79 | 79 | { |
80 | 80 | $variableName = $this->instantiator->filterVariableName($variableName); |
81 | 81 | $paramsString = $this->compileNumberParams($formatString, $absolute); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $this->instantiator->checkCommand($cmd); |
95 | 95 | |
96 | - if($cmd instanceof Mailcode_Commands_Command_ShowNumber) |
|
96 | + if ($cmd instanceof Mailcode_Commands_Command_ShowNumber) |
|
97 | 97 | { |
98 | 98 | return $cmd; |
99 | 99 | } |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | throw $this->instantiator->exceptionUnexpectedType('ShowNumber', $cmd); |
102 | 102 | } |
103 | 103 | |
104 | - private function compileNumberParams(string $formatString="", bool $absolute=false) : string |
|
104 | + private function compileNumberParams(string $formatString = "", bool $absolute = false) : string |
|
105 | 105 | { |
106 | 106 | $params = array(); |
107 | 107 | |
108 | - if(!empty($formatString)) |
|
108 | + if (!empty($formatString)) |
|
109 | 109 | { |
110 | 110 | $params[] = sprintf( |
111 | 111 | ' "%s"', |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | ); |
114 | 114 | } |
115 | 115 | |
116 | - if($absolute) |
|
116 | + if ($absolute) |
|
117 | 117 | { |
118 | 118 | $params[] = ' absolute:'; |
119 | 119 | } |
120 | 120 | |
121 | - if(!empty($params)) |
|
121 | + if (!empty($params)) |
|
122 | 122 | { |
123 | 123 | return ' '.implode(' ', $params); |
124 | 124 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @throws Mailcode_Exception |
137 | 137 | * @throws Mailcode_Factory_Exception |
138 | 138 | */ |
139 | - public function phone(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone |
|
139 | + public function phone(string $variableName, string $sourceFormat, string $urlEncoding = Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone |
|
140 | 140 | { |
141 | 141 | $variableName = $this->instantiator->filterVariableName($variableName); |
142 | 142 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $this->instantiator->checkCommand($cmd); |
160 | 160 | $this->instantiator->setEncoding($cmd, $urlEncoding); |
161 | 161 | |
162 | - if($cmd instanceof Mailcode_Commands_Command_ShowPhone) |
|
162 | + if ($cmd instanceof Mailcode_Commands_Command_ShowPhone) |
|
163 | 163 | { |
164 | 164 | return $cmd; |
165 | 165 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $this->instantiator->checkCommand($cmd); |
182 | 182 | |
183 | - if($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
183 | + if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
184 | 184 | { |
185 | 185 | return $cmd; |
186 | 186 | } |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | public const ERROR_COMMAND_DOES_NOT_EXIST = 45902; |
28 | 28 | public const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903; |
29 | 29 | |
30 | - /** |
|
31 | - * @var Mailcode_Commands_Command[] |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var Mailcode_Commands_Command[] |
|
32 | + */ |
|
33 | 33 | private $commands = array(); |
34 | 34 | |
35 | - /** |
|
36 | - * @var array<string,Mailcode_Commands_Command> |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var array<string,Mailcode_Commands_Command> |
|
37 | + */ |
|
38 | 38 | private static $dummyCommands = array(); |
39 | 39 | |
40 | - /** |
|
41 | - * Retrieves a list of all available command IDs. |
|
42 | - * |
|
43 | - * @return string[] |
|
44 | - */ |
|
40 | + /** |
|
41 | + * Retrieves a list of all available command IDs. |
|
42 | + * |
|
43 | + * @return string[] |
|
44 | + */ |
|
45 | 45 | public function getIDs() : array |
46 | 46 | { |
47 | 47 | static $ids = array(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | return $result; |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * Gets an available command by its ID. |
|
92 | - * |
|
93 | - * @param string $id |
|
94 | - * @return Mailcode_Commands_Command |
|
95 | - */ |
|
90 | + /** |
|
91 | + * Gets an available command by its ID. |
|
92 | + * |
|
93 | + * @param string $id |
|
94 | + * @return Mailcode_Commands_Command |
|
95 | + */ |
|
96 | 96 | public function getByID(string $id) : Mailcode_Commands_Command |
97 | 97 | { |
98 | 98 | static $instances = array(); |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | return $instances[$id]; |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Retrieves the ID of a command by its name. |
|
110 | - * |
|
111 | - * @param string $name |
|
112 | - * @throws Mailcode_Exception |
|
113 | - * @return string |
|
114 | - * |
|
115 | - * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
116 | - */ |
|
108 | + /** |
|
109 | + * Retrieves the ID of a command by its name. |
|
110 | + * |
|
111 | + * @param string $name |
|
112 | + * @throws Mailcode_Exception |
|
113 | + * @return string |
|
114 | + * |
|
115 | + * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
116 | + */ |
|
117 | 117 | public function getIDByName(string $name) : string |
118 | 118 | { |
119 | 119 | $items = $this->getAll(); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | return in_array($id, $ids); |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Checks wether the specified name exists. |
|
147 | - * |
|
148 | - * @param string $name For example: "showvar". |
|
149 | - * @return bool |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Checks wether the specified name exists. |
|
147 | + * |
|
148 | + * @param string $name For example: "showvar". |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | 151 | public function nameExists(string $name) : bool |
152 | 152 | { |
153 | 153 | $items = $this->getAll(); |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | return $class; |
202 | 202 | } |
203 | 203 | |
204 | - /** |
|
205 | - * Translates the command type to the expected class naming scheme. |
|
206 | - * |
|
207 | - * Example: not-empty => NotEmpty |
|
208 | - * |
|
209 | - * @param string $type |
|
210 | - * @return string |
|
211 | - */ |
|
204 | + /** |
|
205 | + * Translates the command type to the expected class naming scheme. |
|
206 | + * |
|
207 | + * Example: not-empty => NotEmpty |
|
208 | + * |
|
209 | + * @param string $type |
|
210 | + * @return string |
|
211 | + */ |
|
212 | 212 | private function adjustTypeName(string $type) : string |
213 | 213 | { |
214 | 214 | $type = str_replace('-', ' ', $type); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public const VALIDATION_NAME_NOHTML = 'nohtml'; |
10 | 10 | |
11 | - public function setHTMLEnabled(bool $enabled=true); |
|
11 | + public function setHTMLEnabled(bool $enabled = true); |
|
12 | 12 | |
13 | 13 | public function isHTMLEnabled() : bool; |
14 | 14 |
@@ -22,9 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | public const REGEX_VARIABLE_NAME = '/\$\s*([A-Z0-9_]+)\s*\.\s*([A-Z0-9_]+)|\$\s*([A-Z0-9_]+)/six'; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Mailcode_Variables_Collection_Regular |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Mailcode_Variables_Collection_Regular |
|
27 | + */ |
|
28 | 28 | protected $collection; |
29 | 29 | |
30 | 30 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | public const ERROR_CSS_FILE_NOT_FOUND = 60901; |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | private $path; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | private $fileName = 'highlight.css'; |
36 | 36 | |
37 | 37 | public function __construct() |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | $this->path = $path; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Retrieves the raw CSS source for the highlighting. |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
57 | + /** |
|
58 | + * Retrieves the raw CSS source for the highlighting. |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | 62 | public function getCSS() : string |
63 | 63 | { |
64 | 64 | return FileHelper::readContents($this->path); |
65 | 65 | } |
66 | 66 | |
67 | - /** |
|
68 | - * Retrieves a fully formed `code` tag with the CSS, |
|
69 | - * to inject inline into an HTML document. |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
67 | + /** |
|
68 | + * Retrieves a fully formed `code` tag with the CSS, |
|
69 | + * to inject inline into an HTML document. |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | 73 | public function getStyleTag() : string |
74 | 74 | { |
75 | 75 | return sprintf( |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Retrieves the path to the stylesheet file. |
|
83 | - * |
|
84 | - * @return string |
|
85 | - */ |
|
81 | + /** |
|
82 | + * Retrieves the path to the stylesheet file. |
|
83 | + * |
|
84 | + * @return string |
|
85 | + */ |
|
86 | 86 | public function getStylesheetPath() : string |
87 | 87 | { |
88 | 88 | return $this->path; |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Retrieves the URL to the stylesheet file, given the |
|
93 | - * local URL to the application's vendor folder. |
|
94 | - * |
|
95 | - * @param string $vendorURL The URL to the vendor folder (must be accessible in the webroot). |
|
96 | - * @return string |
|
97 | - */ |
|
91 | + /** |
|
92 | + * Retrieves the URL to the stylesheet file, given the |
|
93 | + * local URL to the application's vendor folder. |
|
94 | + * |
|
95 | + * @param string $vendorURL The URL to the vendor folder (must be accessible in the webroot). |
|
96 | + * @return string |
|
97 | + */ |
|
98 | 98 | public function getStylesheetURL(string $vendorURL) : string |
99 | 99 | { |
100 | 100 | return sprintf( |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | public const ERROR_CANNOT_RETRIEVE_FIRST_ERROR = 52301; |
26 | 26 | public const ERROR_CANNOT_MODIFY_FINALIZED = 52302; |
27 | 27 | |
28 | - /** |
|
29 | - * @var Mailcode_Commands_Command[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var Mailcode_Commands_Command[] |
|
30 | + */ |
|
31 | 31 | protected $commands = array(); |
32 | 32 | |
33 | 33 | /** |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected $errors = array(); |
37 | 37 | |
38 | - /** |
|
39 | - * @var OperationResult|NULL |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var OperationResult|NULL |
|
40 | + */ |
|
41 | 41 | protected $validationResult; |
42 | 42 | |
43 | 43 | /** |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | return $this; |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Whether there are any commands in the collection. |
|
82 | - * |
|
83 | - * @return bool |
|
84 | - */ |
|
80 | + /** |
|
81 | + * Whether there are any commands in the collection. |
|
82 | + * |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | 85 | public function hasCommands() : bool |
86 | 86 | { |
87 | 87 | return !empty($this->commands); |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * Counts the amount of commands in the collection. |
|
92 | - * |
|
93 | - * @return int |
|
94 | - */ |
|
90 | + /** |
|
91 | + * Counts the amount of commands in the collection. |
|
92 | + * |
|
93 | + * @return int |
|
94 | + */ |
|
95 | 95 | public function countCommands() : int |
96 | 96 | { |
97 | 97 | return count($this->commands); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | $this->commands = $keep; |
130 | 130 | } |
131 | 131 | |
132 | - /** |
|
133 | - * @return Mailcode_Collection_Error[] |
|
134 | - */ |
|
132 | + /** |
|
133 | + * @return Mailcode_Collection_Error[] |
|
134 | + */ |
|
135 | 135 | public function getErrors() |
136 | 136 | { |
137 | 137 | $result = $this->getValidationResult(); |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | return empty($errors); |
174 | 174 | } |
175 | 175 | |
176 | - /** |
|
177 | - * Retrieves all commands that were detected, in the exact order |
|
178 | - * they were found. |
|
179 | - * |
|
180 | - * @return Mailcode_Commands_Command[] |
|
181 | - */ |
|
176 | + /** |
|
177 | + * Retrieves all commands that were detected, in the exact order |
|
178 | + * they were found. |
|
179 | + * |
|
180 | + * @return Mailcode_Commands_Command[] |
|
181 | + */ |
|
182 | 182 | public function getCommands() |
183 | 183 | { |
184 | 184 | $this->validate(); |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
332 | - * Retrieves only show variable commands in the collection, if any. |
|
333 | - * |
|
334 | - * @return Mailcode_Commands_Command_ShowVariable[] |
|
335 | - */ |
|
332 | + * Retrieves only show variable commands in the collection, if any. |
|
333 | + * |
|
334 | + * @return Mailcode_Commands_Command_ShowVariable[] |
|
335 | + */ |
|
336 | 336 | public function getShowVariableCommands(): array |
337 | 337 | { |
338 | 338 | return $this->getCommandsByClass(Mailcode_Commands_Command_ShowVariable::class); |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | return $this->getCommandsByClass(Mailcode_Commands_Command_For::class); |
347 | 347 | } |
348 | 348 | |
349 | - /** |
|
350 | - * Retrieves only show date commands in the collection, if any. |
|
351 | - * |
|
352 | - * @return Mailcode_Commands_Command_ShowDate[] |
|
353 | - */ |
|
349 | + /** |
|
350 | + * Retrieves only show date commands in the collection, if any. |
|
351 | + * |
|
352 | + * @return Mailcode_Commands_Command_ShowDate[] |
|
353 | + */ |
|
354 | 354 | public function getShowDateCommands() : array |
355 | 355 | { |
356 | 356 | return $this->getCommandsByClass(Mailcode_Commands_Command_ShowDate::class); |
@@ -52,45 +52,45 @@ discard block |
||
52 | 52 | public const ERROR_INVALID_COMMANDS = 47801; |
53 | 53 | public const ERROR_PLACEHOLDER_NOT_FOUND = 47804; |
54 | 54 | |
55 | - /** |
|
56 | - * @var Mailcode_Parser |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var Mailcode_Parser |
|
57 | + */ |
|
58 | 58 | protected $parser; |
59 | 59 | |
60 | - /** |
|
61 | - * @var Mailcode_Collection |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var Mailcode_Collection |
|
62 | + */ |
|
63 | 63 | protected $commands; |
64 | 64 | |
65 | - /** |
|
66 | - * @var string |
|
67 | - */ |
|
65 | + /** |
|
66 | + * @var string |
|
67 | + */ |
|
68 | 68 | protected $originalString; |
69 | 69 | |
70 | - /** |
|
71 | - * @var Mailcode_Collection |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var Mailcode_Collection |
|
72 | + */ |
|
73 | 73 | protected $collection; |
74 | 74 | |
75 | - /** |
|
76 | - * Counter for the placeholders, global for all placeholders. |
|
77 | - * @var integer |
|
78 | - */ |
|
75 | + /** |
|
76 | + * Counter for the placeholders, global for all placeholders. |
|
77 | + * @var integer |
|
78 | + */ |
|
79 | 79 | private static $counter = 0; |
80 | 80 | |
81 | - /** |
|
82 | - * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
83 | - */ |
|
81 | + /** |
|
82 | + * @var Mailcode_Parser_Safeguard_Placeholder[] |
|
83 | + */ |
|
84 | 84 | protected $placeholders; |
85 | 85 | |
86 | - /** |
|
87 | - * @var string |
|
88 | - */ |
|
86 | + /** |
|
87 | + * @var string |
|
88 | + */ |
|
89 | 89 | protected $delimiter = '999'; |
90 | 90 | |
91 | - /** |
|
92 | - * @var string[]|NULL |
|
93 | - */ |
|
91 | + /** |
|
92 | + * @var string[]|NULL |
|
93 | + */ |
|
94 | 94 | protected $placeholderStrings; |
95 | 95 | |
96 | 96 | public function __construct(Mailcode_Parser $parser, string $subject) |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | self::$counter = 0; |
110 | 110 | } |
111 | 111 | |
112 | - /** |
|
113 | - * Retrieves the string the safeguard was created for. |
|
114 | - * |
|
115 | - * @return string |
|
116 | - */ |
|
112 | + /** |
|
113 | + * Retrieves the string the safeguard was created for. |
|
114 | + * |
|
115 | + * @return string |
|
116 | + */ |
|
117 | 117 | public function getOriginalString() : string |
118 | 118 | { |
119 | 119 | return $this->originalString; |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Sets the delimiter character sequence used to prepend |
|
124 | - * and append to the placeholders. |
|
125 | - * |
|
126 | - * The delimiter's default is "999". |
|
127 | - * |
|
128 | - * Minimum characters: 2 |
|
129 | - * Invalid characters: Any characters that get URL encoded |
|
130 | - * |
|
131 | - * @param string $delimiter |
|
132 | - * @return Mailcode_Parser_Safeguard |
|
133 | - */ |
|
122 | + /** |
|
123 | + * Sets the delimiter character sequence used to prepend |
|
124 | + * and append to the placeholders. |
|
125 | + * |
|
126 | + * The delimiter's default is "999". |
|
127 | + * |
|
128 | + * Minimum characters: 2 |
|
129 | + * Invalid characters: Any characters that get URL encoded |
|
130 | + * |
|
131 | + * @param string $delimiter |
|
132 | + * @return Mailcode_Parser_Safeguard |
|
133 | + */ |
|
134 | 134 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
135 | 135 | { |
136 | 136 | $validator = new Mailcode_Parser_Safeguard_DelimiterValidator($delimiter); |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | return $this->delimiter; |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Retrieves the safe string in which all commands have been replaced |
|
151 | - * by placeholder strings. |
|
152 | - * |
|
153 | - * @return string |
|
154 | - * @throws Mailcode_Exception |
|
155 | - * |
|
156 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
157 | - */ |
|
149 | + /** |
|
150 | + * Retrieves the safe string in which all commands have been replaced |
|
151 | + * by placeholder strings. |
|
152 | + * |
|
153 | + * @return string |
|
154 | + * @throws Mailcode_Exception |
|
155 | + * |
|
156 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
157 | + */ |
|
158 | 158 | public function makeSafe() : string |
159 | 159 | { |
160 | 160 | $this->requireValidCollection(); |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | return $this->makeSafePartial(); |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Like makeSafe(), but allows partial (invalid) commands: use this |
|
167 | - * if the subject string may contain only part of the whole set of |
|
168 | - * commands. |
|
169 | - * |
|
170 | - * Example: parsing a text with an opening if statement, without the |
|
171 | - * matching end statement. |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
165 | + /** |
|
166 | + * Like makeSafe(), but allows partial (invalid) commands: use this |
|
167 | + * if the subject string may contain only part of the whole set of |
|
168 | + * commands. |
|
169 | + * |
|
170 | + * Example: parsing a text with an opening if statement, without the |
|
171 | + * matching end statement. |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | 175 | public function makeSafePartial() : string |
176 | 176 | { |
177 | 177 | $placeholders = $this->getPlaceholders(); |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | $analyzer->analyze(); |
256 | 256 | } |
257 | 257 | |
258 | - /** |
|
259 | - * Creates a formatting handler, which can be used to specify |
|
260 | - * which formattings to use for the commands in the subject string. |
|
261 | - * |
|
262 | - * @param Mailcode_StringContainer|string $subject |
|
263 | - * @return Mailcode_Parser_Safeguard_Formatting |
|
264 | - */ |
|
258 | + /** |
|
259 | + * Creates a formatting handler, which can be used to specify |
|
260 | + * which formattings to use for the commands in the subject string. |
|
261 | + * |
|
262 | + * @param Mailcode_StringContainer|string $subject |
|
263 | + * @return Mailcode_Parser_Safeguard_Formatting |
|
264 | + */ |
|
265 | 265 | public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting |
266 | 266 | { |
267 | 267 | if(is_string($subject)) |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | return new Mailcode_Parser_Safeguard_Formatting($this, $subject); |
273 | 273 | } |
274 | 274 | |
275 | - /** |
|
276 | - * Retrieves all placeholders that have to be added to |
|
277 | - * the subject text. |
|
278 | - * |
|
279 | - * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
280 | - */ |
|
275 | + /** |
|
276 | + * Retrieves all placeholders that have to be added to |
|
277 | + * the subject text. |
|
278 | + * |
|
279 | + * @return \Mailcode\Mailcode_Parser_Safeguard_Placeholder[] |
|
280 | + */ |
|
281 | 281 | public function getPlaceholders() |
282 | 282 | { |
283 | 283 | if(isset($this->placeholders)) |
@@ -353,16 +353,16 @@ discard block |
||
353 | 353 | return $string; |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Makes the string whole again after transforming or filtering it, |
|
358 | - * by replacing the command placeholders with the original commands. |
|
359 | - * |
|
360 | - * @param string $string |
|
361 | - * @return string |
|
362 | - * @throws Mailcode_Exception |
|
363 | - * |
|
364 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
365 | - */ |
|
356 | + /** |
|
357 | + * Makes the string whole again after transforming or filtering it, |
|
358 | + * by replacing the command placeholders with the original commands. |
|
359 | + * |
|
360 | + * @param string $string |
|
361 | + * @return string |
|
362 | + * @throws Mailcode_Exception |
|
363 | + * |
|
364 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
365 | + */ |
|
366 | 366 | public function makeWhole(string $string) : string |
367 | 367 | { |
368 | 368 | return $this->restore( |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | ); |
373 | 373 | } |
374 | 374 | |
375 | - /** |
|
376 | - * Like `makeWhole()`, but ignores missing command placeholders. |
|
377 | - * |
|
378 | - * @param string $string |
|
379 | - * @return string |
|
380 | - * @throws Mailcode_Exception |
|
381 | - * |
|
382 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
383 | - */ |
|
375 | + /** |
|
376 | + * Like `makeWhole()`, but ignores missing command placeholders. |
|
377 | + * |
|
378 | + * @param string $string |
|
379 | + * @return string |
|
380 | + * @throws Mailcode_Exception |
|
381 | + * |
|
382 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
383 | + */ |
|
384 | 384 | public function makeWholePartial(string $string) : string |
385 | 385 | { |
386 | 386 | return $this->restore( |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | ); |
391 | 391 | } |
392 | 392 | |
393 | - /** |
|
394 | - * Like `makeWhole()`, but replaces the commands with a syntax |
|
395 | - * highlighted version, meant for human readable texts only. |
|
396 | - * |
|
397 | - * Note: the commands lose their functionality (They cannot be |
|
398 | - * parsed from that string again). |
|
399 | - * |
|
400 | - * @param string $string |
|
401 | - * @return string |
|
402 | - * @throws Mailcode_Exception |
|
403 | - * |
|
404 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
405 | - */ |
|
393 | + /** |
|
394 | + * Like `makeWhole()`, but replaces the commands with a syntax |
|
395 | + * highlighted version, meant for human readable texts only. |
|
396 | + * |
|
397 | + * Note: the commands lose their functionality (They cannot be |
|
398 | + * parsed from that string again). |
|
399 | + * |
|
400 | + * @param string $string |
|
401 | + * @return string |
|
402 | + * @throws Mailcode_Exception |
|
403 | + * |
|
404 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
405 | + */ |
|
406 | 406 | public function makeHighlighted(string $string) : string |
407 | 407 | { |
408 | 408 | return $this->restore( |
@@ -412,15 +412,15 @@ discard block |
||
412 | 412 | ); |
413 | 413 | } |
414 | 414 | |
415 | - /** |
|
416 | - * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
417 | - * |
|
418 | - * @param string $string |
|
419 | - * @return string |
|
420 | - * @throws Mailcode_Exception |
|
421 | - * |
|
422 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
423 | - */ |
|
415 | + /** |
|
416 | + * Like `makeHighlighted()`, but ignores missing command placeholders. |
|
417 | + * |
|
418 | + * @param string $string |
|
419 | + * @return string |
|
420 | + * @throws Mailcode_Exception |
|
421 | + * |
|
422 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
423 | + */ |
|
424 | 424 | public function makeHighlightedPartial(string $string) : string |
425 | 425 | { |
426 | 426 | return $this->restore( |
@@ -430,11 +430,11 @@ discard block |
||
430 | 430 | ); |
431 | 431 | } |
432 | 432 | |
433 | - /** |
|
434 | - * Retrieves the commands collection contained in the string. |
|
435 | - * |
|
436 | - * @return Mailcode_Collection |
|
437 | - */ |
|
433 | + /** |
|
434 | + * Retrieves the commands collection contained in the string. |
|
435 | + * |
|
436 | + * @return Mailcode_Collection |
|
437 | + */ |
|
438 | 438 | public function getCollection() : Mailcode_Collection |
439 | 439 | { |
440 | 440 | if(isset($this->collection)) |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | return $this->getCollection()->isValid(); |
453 | 453 | } |
454 | 454 | |
455 | - /** |
|
456 | - * @throws Mailcode_Exception |
|
457 | - * |
|
458 | - * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
459 | - */ |
|
455 | + /** |
|
456 | + * @throws Mailcode_Exception |
|
457 | + * |
|
458 | + * @see Mailcode_Parser_Safeguard::ERROR_INVALID_COMMANDS |
|
459 | + */ |
|
460 | 460 | protected function requireValidCollection() : void |
461 | 461 | { |
462 | 462 | if($this->getCollection()->isValid()) |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | throw $exception; |
480 | 480 | } |
481 | 481 | |
482 | - /** |
|
483 | - * Retrieves a list of all placeholder IDs used in the text. |
|
484 | - * |
|
485 | - * @return string[] |
|
486 | - */ |
|
482 | + /** |
|
483 | + * Retrieves a list of all placeholder IDs used in the text. |
|
484 | + * |
|
485 | + * @return string[] |
|
486 | + */ |
|
487 | 487 | public function getPlaceholderStrings() : array |
488 | 488 | { |
489 | 489 | if(is_array($this->placeholderStrings)) |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | return in_array($subject, $ids, true); |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Retrieves a placeholder instance by its ID. |
|
515 | - * |
|
516 | - * @param int $id |
|
517 | - * @throws Mailcode_Exception If the placeholder was not found. |
|
518 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
519 | - */ |
|
513 | + /** |
|
514 | + * Retrieves a placeholder instance by its ID. |
|
515 | + * |
|
516 | + * @param int $id |
|
517 | + * @throws Mailcode_Exception If the placeholder was not found. |
|
518 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
519 | + */ |
|
520 | 520 | public function getPlaceholderByID(int $id) : Mailcode_Parser_Safeguard_Placeholder |
521 | 521 | { |
522 | 522 | $placeholders = $this->getPlaceholders(); |
@@ -539,13 +539,13 @@ discard block |
||
539 | 539 | ); |
540 | 540 | } |
541 | 541 | |
542 | - /** |
|
543 | - * Retrieves a placeholder instance by its replacement text. |
|
544 | - * |
|
545 | - * @param string $string |
|
546 | - * @throws Mailcode_Exception |
|
547 | - * @return Mailcode_Parser_Safeguard_Placeholder |
|
548 | - */ |
|
542 | + /** |
|
543 | + * Retrieves a placeholder instance by its replacement text. |
|
544 | + * |
|
545 | + * @param string $string |
|
546 | + * @throws Mailcode_Exception |
|
547 | + * @return Mailcode_Parser_Safeguard_Placeholder |
|
548 | + */ |
|
549 | 549 | public function getPlaceholderByString(string $string) : Mailcode_Parser_Safeguard_Placeholder |
550 | 550 | { |
551 | 551 | $placeholders = $this->getPlaceholders(); |