@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | |
32 | 32 | private string $paramsString; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string[] |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string[] |
|
36 | + */ |
|
37 | 37 | private array $names = array( |
38 | 38 | 'and', |
39 | 39 | 'or' |
40 | 40 | ); |
41 | 41 | |
42 | - /** |
|
43 | - * @var Mailcode_Commands_LogicKeywords_Keyword[] |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var Mailcode_Commands_LogicKeywords_Keyword[] |
|
44 | + */ |
|
45 | 45 | private array $keywords = array(); |
46 | 46 | |
47 | 47 | private string $mainParams = ''; |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * @return string[] |
|
133 | - */ |
|
131 | + /** |
|
132 | + * @return string[] |
|
133 | + */ |
|
134 | 134 | private function detectParameters() : array |
135 | 135 | { |
136 | 136 | $params = $this->paramsString; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | return $stack; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * @param string $params |
|
153 | - * @param Mailcode_Commands_LogicKeywords_Keyword $keyword |
|
154 | - * @param string[] $stack |
|
155 | - * @throws Mailcode_Exception |
|
156 | - * @return string |
|
157 | - */ |
|
151 | + /** |
|
152 | + * @param string $params |
|
153 | + * @param Mailcode_Commands_LogicKeywords_Keyword $keyword |
|
154 | + * @param string[] $stack |
|
155 | + * @throws Mailcode_Exception |
|
156 | + * @return string |
|
157 | + */ |
|
158 | 158 | private function detectParamsKeyword(string $params, Mailcode_Commands_LogicKeywords_Keyword $keyword, array &$stack) : string |
159 | 159 | { |
160 | 160 | $search = $keyword->getMatchedString(); |
@@ -189,22 +189,22 @@ discard block |
||
189 | 189 | return $params; |
190 | 190 | } |
191 | 191 | |
192 | - /** |
|
193 | - * Extracts the parameters string to use for the |
|
194 | - * original command itself, omitting all the logic |
|
195 | - * keywords for the sub-commands. |
|
196 | - * |
|
197 | - * @return string |
|
198 | - */ |
|
192 | + /** |
|
193 | + * Extracts the parameters string to use for the |
|
194 | + * original command itself, omitting all the logic |
|
195 | + * keywords for the sub-commands. |
|
196 | + * |
|
197 | + * @return string |
|
198 | + */ |
|
199 | 199 | public function getMainParamsString() : string |
200 | 200 | { |
201 | 201 | return $this->mainParams; |
202 | 202 | } |
203 | 203 | |
204 | - /** |
|
205 | - * Retrieves the detected keyword names. |
|
206 | - * @return string[] |
|
207 | - */ |
|
204 | + /** |
|
205 | + * Retrieves the detected keyword names. |
|
206 | + * @return string[] |
|
207 | + */ |
|
208 | 208 | public function getDetectedNames() : array |
209 | 209 | { |
210 | 210 | $names = array(); |
@@ -221,23 +221,23 @@ discard block |
||
221 | 221 | return $names; |
222 | 222 | } |
223 | 223 | |
224 | - /** |
|
225 | - * Retrieves all keywords detected in the |
|
226 | - * command's parameter string, if any. |
|
227 | - * |
|
228 | - * @return Mailcode_Commands_LogicKeywords_Keyword[] |
|
229 | - */ |
|
224 | + /** |
|
225 | + * Retrieves all keywords detected in the |
|
226 | + * command's parameter string, if any. |
|
227 | + * |
|
228 | + * @return Mailcode_Commands_LogicKeywords_Keyword[] |
|
229 | + */ |
|
230 | 230 | public function getKeywords() : array |
231 | 231 | { |
232 | 232 | return $this->keywords; |
233 | 233 | } |
234 | 234 | |
235 | - /** |
|
236 | - * Detects any keyword statements in the parameters by keyword name. |
|
237 | - * |
|
238 | - * @param string $name |
|
239 | - * @return Mailcode_Commands_LogicKeywords_Keyword[] |
|
240 | - */ |
|
235 | + /** |
|
236 | + * Detects any keyword statements in the parameters by keyword name. |
|
237 | + * |
|
238 | + * @param string $name |
|
239 | + * @return Mailcode_Commands_LogicKeywords_Keyword[] |
|
240 | + */ |
|
241 | 241 | private function detectKeywords(string $name) : array |
242 | 242 | { |
243 | 243 | $regex = sprintf('/%1$s\s+([a-z\-0-9]+):|%1$s:/x', $name); |
@@ -23,39 +23,39 @@ discard block |
||
23 | 23 | public const ERROR_INVALID_CALLABLE = 65701; |
24 | 24 | public const ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION = 65702; |
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | 29 | private $subject; |
30 | 30 | |
31 | - /** |
|
32 | - * @var integer |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var integer |
|
33 | + */ |
|
34 | 34 | private static $listenerCounter = 0; |
35 | 35 | |
36 | - /** |
|
37 | - * @var callable[] |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var callable[] |
|
38 | + */ |
|
39 | 39 | private $listeners = array(); |
40 | 40 | |
41 | - /** |
|
42 | - * @var boolean |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var boolean |
|
43 | + */ |
|
44 | 44 | private $updating = false; |
45 | 45 | |
46 | - /** |
|
47 | - * @var integer |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var integer |
|
48 | + */ |
|
49 | 49 | private static $idCounter = 0; |
50 | 50 | |
51 | - /** |
|
52 | - * @var integer |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var integer |
|
53 | + */ |
|
54 | 54 | private $id; |
55 | 55 | |
56 | - /** |
|
57 | - * @var integer |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var integer |
|
58 | + */ |
|
59 | 59 | private $length; |
60 | 60 | |
61 | 61 | public function __construct(string $subject) |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | return $this->id; |
73 | 73 | } |
74 | 74 | |
75 | - /** |
|
76 | - * Updates the string with the specified string. |
|
77 | - * Notifies all listeners of the change. |
|
78 | - * |
|
79 | - * @param string $subject |
|
80 | - * @throws Mailcode_Exception |
|
81 | - * @return bool Whether the string had modifications. |
|
82 | - * |
|
83 | - * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION |
|
84 | - */ |
|
75 | + /** |
|
76 | + * Updates the string with the specified string. |
|
77 | + * Notifies all listeners of the change. |
|
78 | + * |
|
79 | + * @param string $subject |
|
80 | + * @throws Mailcode_Exception |
|
81 | + * @return bool Whether the string had modifications. |
|
82 | + * |
|
83 | + * @see Mailcode_StringContainer::ERROR_UPDATE_CALLED_DURING_UPDATE_OPERATION |
|
84 | + */ |
|
85 | 85 | public function updateString(string $subject) : bool |
86 | 86 | { |
87 | 87 | // avoid triggering an update if there are no changes in the string |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Retrieves the stored string. |
|
119 | - * |
|
120 | - * @return string |
|
121 | - */ |
|
117 | + /** |
|
118 | + * Retrieves the stored string. |
|
119 | + * |
|
120 | + * @return string |
|
121 | + */ |
|
122 | 122 | public function getString() : string |
123 | 123 | { |
124 | 124 | return $this->subject; |
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
128 | - * Adds a listener that will be informed every time the string is modified. |
|
129 | - * The callback gets the string container instance as parameter. |
|
130 | - * |
|
131 | - * @param callable|mixed $callback |
|
132 | - * @throws Mailcode_Exception If it is not a valid callable. |
|
133 | - * @return int The listener number, to be able to remove it using `removeListener()`. |
|
134 | - * |
|
135 | - * @see Mailcode_StringContainer::removeListener() |
|
136 | - * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE |
|
137 | - */ |
|
127 | + /** |
|
128 | + * Adds a listener that will be informed every time the string is modified. |
|
129 | + * The callback gets the string container instance as parameter. |
|
130 | + * |
|
131 | + * @param callable|mixed $callback |
|
132 | + * @throws Mailcode_Exception If it is not a valid callable. |
|
133 | + * @return int The listener number, to be able to remove it using `removeListener()`. |
|
134 | + * |
|
135 | + * @see Mailcode_StringContainer::removeListener() |
|
136 | + * @see Mailcode_StringContainer::ERROR_INVALID_CALLABLE |
|
137 | + */ |
|
138 | 138 | public function addListener($callback) : int |
139 | 139 | { |
140 | 140 | self::$listenerCounter++; |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | return $this->length; |
162 | 162 | } |
163 | 163 | |
164 | - /** |
|
165 | - * Removes an existing listener by its ID. |
|
166 | - * Has no effect if it does not exist, or has already been removed. |
|
167 | - * |
|
168 | - * @param int $listenerID |
|
169 | - */ |
|
164 | + /** |
|
165 | + * Removes an existing listener by its ID. |
|
166 | + * Has no effect if it does not exist, or has already been removed. |
|
167 | + * |
|
168 | + * @param int $listenerID |
|
169 | + */ |
|
170 | 170 | public function removeListener(int $listenerID) : void |
171 | 171 | { |
172 | 172 | if(isset($this->listeners[$listenerID])) |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Replaces all substrings matching needle with the replacement text. |
|
180 | - * |
|
181 | - * @param string $needle |
|
182 | - * @param string $replacement |
|
183 | - * @return bool |
|
184 | - */ |
|
178 | + /** |
|
179 | + * Replaces all substrings matching needle with the replacement text. |
|
180 | + * |
|
181 | + * @param string $needle |
|
182 | + * @param string $replacement |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | 185 | public function replaceSubstrings(string $needle, string $replacement) : bool |
186 | 186 | { |
187 | 187 | $string = str_replace($needle, $replacement, $this->subject); |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | return $this->updateString($string); |
190 | 190 | } |
191 | 191 | |
192 | - /** |
|
193 | - * Get the position of a substring in the string. |
|
194 | - * |
|
195 | - * @param string $needle |
|
196 | - * @return int|bool The zero-based position, or false if not found. |
|
197 | - */ |
|
192 | + /** |
|
193 | + * Get the position of a substring in the string. |
|
194 | + * |
|
195 | + * @param string $needle |
|
196 | + * @return int|bool The zero-based position, or false if not found. |
|
197 | + */ |
|
198 | 198 | public function getSubstrPosition(string $needle) |
199 | 199 | { |
200 | 200 | return mb_strpos($this->subject, $needle); |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Creates a new mailcode instance. |
|
64 | - * @return Mailcode |
|
65 | - */ |
|
62 | + /** |
|
63 | + * Creates a new mailcode instance. |
|
64 | + * @return Mailcode |
|
65 | + */ |
|
66 | 66 | public static function create() : Mailcode |
67 | 67 | { |
68 | 68 | return new Mailcode(); |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Parses the string to detect all commands contained within. |
|
78 | - * |
|
79 | - * @param string $string |
|
80 | - * @return Mailcode_Collection |
|
81 | - */ |
|
77 | + * Parses the string to detect all commands contained within. |
|
78 | + * |
|
79 | + * @param string $string |
|
80 | + * @return Mailcode_Collection |
|
81 | + */ |
|
82 | 82 | public function parseString(string $string) : Mailcode_Collection |
83 | 83 | { |
84 | 84 | return $this->getParser() |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | ->getCollection(); |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Retrieves the string parser instance used to detect commands. |
|
91 | - * |
|
92 | - * @return Mailcode_Parser |
|
93 | - */ |
|
89 | + /** |
|
90 | + * Retrieves the string parser instance used to detect commands. |
|
91 | + * |
|
92 | + * @return Mailcode_Parser |
|
93 | + */ |
|
94 | 94 | public function getParser() : Mailcode_Parser |
95 | 95 | { |
96 | 96 | if(!isset($this->parser)) |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | return $this->parser; |
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
105 | - * Retrieves the commands collection, which is used to |
|
106 | - * access information on the available commands. |
|
107 | - * |
|
108 | - * @return Mailcode_Commands |
|
109 | - */ |
|
104 | + /** |
|
105 | + * Retrieves the commands collection, which is used to |
|
106 | + * access information on the available commands. |
|
107 | + * |
|
108 | + * @return Mailcode_Commands |
|
109 | + */ |
|
110 | 110 | public function getCommands() : Mailcode_Commands |
111 | 111 | { |
112 | 112 | if(!isset($this->commands)) |
@@ -149,23 +149,23 @@ discard block |
||
149 | 149 | return $this->variables; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Creates the translator, which can be used to convert commands |
|
154 | - * to another supported syntax. |
|
155 | - * |
|
156 | - * @return Mailcode_Translator |
|
157 | - */ |
|
152 | + /** |
|
153 | + * Creates the translator, which can be used to convert commands |
|
154 | + * to another supported syntax. |
|
155 | + * |
|
156 | + * @return Mailcode_Translator |
|
157 | + */ |
|
158 | 158 | public function createTranslator() : Mailcode_Translator |
159 | 159 | { |
160 | 160 | return Mailcode_Translator::create(); |
161 | 161 | } |
162 | 162 | |
163 | - /** |
|
164 | - * Creates the styler, which can be used to retrieve the |
|
165 | - * CSS required to style the highlighted commands in HTML. |
|
166 | - * |
|
167 | - * @return Mailcode_Styler |
|
168 | - */ |
|
163 | + /** |
|
164 | + * Creates the styler, which can be used to retrieve the |
|
165 | + * CSS required to style the highlighted commands in HTML. |
|
166 | + * |
|
167 | + * @return Mailcode_Styler |
|
168 | + */ |
|
169 | 169 | public function createStyler() : Mailcode_Styler |
170 | 170 | { |
171 | 171 | return new Mailcode_Styler(); |