@@ -62,7 +62,7 @@ |
||
62 | 62 | $keyword = $info->getKeywordByIndex(1); |
63 | 63 | $container = $info->getVariableByIndex(2); |
64 | 64 | |
65 | - if($variable && $keyword && $container && $keyword->isForIn()) |
|
65 | + if ($variable && $keyword && $container && $keyword->isForIn()) |
|
66 | 66 | { |
67 | 67 | return; |
68 | 68 | } |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Commands_Highlighter |
22 | 22 | { |
23 | - /** |
|
24 | - * @var Mailcode_Commands_Command |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var Mailcode_Commands_Command |
|
25 | + */ |
|
26 | 26 | protected $command; |
27 | 27 | |
28 | - /** |
|
29 | - * @var string[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string[] |
|
30 | + */ |
|
31 | 31 | protected $parts = array(); |
32 | 32 | |
33 | 33 | public function __construct(Mailcode_Commands_Command $command) |
34 | 34 | { |
35 | - $this->command = $command; |
|
35 | + $this->command = $command; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function highlight() : string |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * @param string[] $classes |
|
73 | - * @param string $content |
|
74 | - * @return string |
|
75 | - */ |
|
71 | + /** |
|
72 | + * @param string[] $classes |
|
73 | + * @param string $content |
|
74 | + * @return string |
|
75 | + */ |
|
76 | 76 | protected function renderTag(array $classes, string $content) : string |
77 | 77 | { |
78 | 78 | $parts = array(); |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | { |
52 | 52 | $this->parts[] = $this->renderTag(array('command-name'), $this->command->getName()); |
53 | 53 | |
54 | - if($this->command->hasType()) |
|
54 | + if ($this->command->hasType()) |
|
55 | 55 | { |
56 | 56 | $this->parts[] = ' '.$this->renderTag(array('command-type'), $this->command->getType()); |
57 | 57 | } |
58 | 58 | |
59 | - if($this->command->requiresParameters()) |
|
59 | + if ($this->command->requiresParameters()) |
|
60 | 60 | { |
61 | 61 | $this->parts[] = $this->renderTag(array('hyphen'), ':'); |
62 | 62 | $this->parts[] = '<wbr>'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | protected function appendParams() : void |
67 | 67 | { |
68 | - if($this->command->hasParameters()) |
|
68 | + if ($this->command->hasParameters()) |
|
69 | 69 | { |
70 | 70 | $this->parts[] = ' '.$this->renderTag(array('params'), $this->command->getParamsString()); |
71 | 71 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $parts = array(); |
82 | 82 | |
83 | - foreach($classes as $class) |
|
83 | + foreach ($classes as $class) |
|
84 | 84 | { |
85 | 85 | $parts[] = 'mailcode-'.$class; |
86 | 86 | } |
@@ -32,34 +32,34 @@ |
||
32 | 32 | const VALIDATION_ERROR_PATH_UNDERSCORE = 48203; |
33 | 33 | const VALIDATION_ERROR_NAME_UNDERSCORE = 48204; |
34 | 34 | |
35 | - /** |
|
36 | - * @var string |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + */ |
|
38 | 38 | protected $path; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $name; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + */ |
|
48 | 48 | protected $matchedText; |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $hash = ''; |
54 | 54 | |
55 | - /** |
|
56 | - * @var OperationResult |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var OperationResult |
|
57 | + */ |
|
58 | 58 | protected $validationResult = null; |
59 | 59 | |
60 | - /** |
|
61 | - * @var array<string> |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var array<string> |
|
62 | + */ |
|
63 | 63 | protected $validations = array( |
64 | 64 | 'number_path', |
65 | 65 | 'number_name', |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function getFullName() : string |
78 | 78 | { |
79 | - if(empty($this->path)) |
|
79 | + if (empty($this->path)) |
|
80 | 80 | { |
81 | 81 | return '$'.$this->name; |
82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function getHash() : string |
103 | 103 | { |
104 | - if(empty($this->hash)) |
|
104 | + if (empty($this->hash)) |
|
105 | 105 | { |
106 | 106 | $this->hash = md5($this->matchedText); |
107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function getValidationResult() : OperationResult |
118 | 118 | { |
119 | - if(isset($this->validationResult)) |
|
119 | + if (isset($this->validationResult)) |
|
120 | 120 | { |
121 | 121 | return $this->validationResult; |
122 | 122 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | |
131 | 131 | protected function validate() : void |
132 | 132 | { |
133 | - foreach($this->validations as $validation) |
|
133 | + foreach ($this->validations as $validation) |
|
134 | 134 | { |
135 | 135 | $method = 'validate_'.$validation; |
136 | 136 | |
137 | - if(!method_exists($this, $method)) |
|
137 | + if (!method_exists($this, $method)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Unknown validation method', |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $this->$method(); |
151 | 151 | |
152 | - if(!$this->validationResult->isValid()) |
|
152 | + if (!$this->validationResult->isValid()) |
|
153 | 153 | { |
154 | 154 | return; |
155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | protected function validateNumber(string $value, int $errorCode) : void |
180 | 180 | { |
181 | - if(!is_numeric(substr($value, 0, 1))) |
|
181 | + if (!is_numeric(substr($value, 0, 1))) |
|
182 | 182 | { |
183 | 183 | return; |
184 | 184 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | protected function validateUnderscore(string $value, int $errorCode) : void |
197 | 197 | { |
198 | 198 | // allow empty paths |
199 | - if(empty($value)) |
|
199 | + if (empty($value)) |
|
200 | 200 | { |
201 | 201 | return; |
202 | 202 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $length = strlen($value); |
205 | 205 | |
206 | 206 | // trimming underscores does not change the length: no underscores at start or end of string. |
207 | - if(strlen(trim($value, '_')) == $length) |
|
207 | + if (strlen(trim($value, '_')) == $length) |
|
208 | 208 | { |
209 | 209 | return; |
210 | 210 | } |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | abstract class Mailcode_Variables_Collection |
22 | 22 | { |
23 | - /** |
|
24 | - * @var Mailcode_Variables_Variable[] |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var Mailcode_Variables_Variable[] |
|
25 | + */ |
|
26 | 26 | protected $variables = array(); |
27 | 27 | |
28 | 28 | public function __construct() |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | return count($this->variables); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Checks whether the collection contains a variable with the specified name. |
|
57 | - * |
|
58 | - * @param string $fullName The variable name, with or without $ sign. |
|
59 | - * @return bool |
|
60 | - */ |
|
55 | + /** |
|
56 | + * Checks whether the collection contains a variable with the specified name. |
|
57 | + * |
|
58 | + * @param string $fullName The variable name, with or without $ sign. |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | 61 | public function hasVariableName(string $fullName) : bool |
62 | 62 | { |
63 | 63 | $fullName = $this->fixName($fullName); |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - /** |
|
77 | - * Retrieves a collection of all variable instances for |
|
78 | - * the specified name (there can be several with differing |
|
79 | - * matched texts because of spacing). |
|
80 | - * |
|
81 | - * @param string $fullName |
|
82 | - * @return Mailcode_Variables_Collection |
|
83 | - */ |
|
76 | + /** |
|
77 | + * Retrieves a collection of all variable instances for |
|
78 | + * the specified name (there can be several with differing |
|
79 | + * matched texts because of spacing). |
|
80 | + * |
|
81 | + * @param string $fullName |
|
82 | + * @return Mailcode_Variables_Collection |
|
83 | + */ |
|
84 | 84 | public function getByFullName(string $fullName) : Mailcode_Variables_Collection |
85 | 85 | { |
86 | 86 | $fullName = $this->fixName($fullName); |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | return $collection; |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Prepends the $ sign to a variable name if it does not have it. |
|
103 | - * |
|
104 | - * @param string $fullName |
|
105 | - * @return string |
|
106 | - */ |
|
101 | + /** |
|
102 | + * Prepends the $ sign to a variable name if it does not have it. |
|
103 | + * |
|
104 | + * @param string $fullName |
|
105 | + * @return string |
|
106 | + */ |
|
107 | 107 | protected function fixName(string $fullName) : string |
108 | 108 | { |
109 | 109 | if(substr($fullName, 0, 1) === '$') |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | return '$'.$fullName; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Retrieves all variables, grouped by their hash - meaning |
|
119 | - * unique matched strings. |
|
120 | - * |
|
121 | - * @return Mailcode_Variables_Variable[] |
|
122 | - */ |
|
117 | + /** |
|
118 | + * Retrieves all variables, grouped by their hash - meaning |
|
119 | + * unique matched strings. |
|
120 | + * |
|
121 | + * @return Mailcode_Variables_Variable[] |
|
122 | + */ |
|
123 | 123 | public function getGroupedByHash() |
124 | 124 | { |
125 | 125 | $entries = array(); |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | return $this->sortVariables($entries); |
133 | 133 | } |
134 | 134 | |
135 | - /** |
|
136 | - * Retrieves all variables, grouped by their name. |
|
137 | - * |
|
138 | - * @return Mailcode_Variables_Variable[] |
|
139 | - */ |
|
135 | + /** |
|
136 | + * Retrieves all variables, grouped by their name. |
|
137 | + * |
|
138 | + * @return Mailcode_Variables_Variable[] |
|
139 | + */ |
|
140 | 140 | public function getGroupedByName() |
141 | 141 | { |
142 | 142 | $entries = array(); |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | return $this->sortVariables($entries); |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Retrieves all variables, in the order they were addded. |
|
154 | - * @return \Mailcode\Mailcode_Variables_Variable[] |
|
155 | - */ |
|
152 | + /** |
|
153 | + * Retrieves all variables, in the order they were addded. |
|
154 | + * @return \Mailcode\Mailcode_Variables_Variable[] |
|
155 | + */ |
|
156 | 156 | public function getAll() |
157 | 157 | { |
158 | 158 | return $this->variables; |
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
162 | - * Retrieves the full names of the variables that are present in the collection. |
|
163 | - * @return string[] |
|
164 | - */ |
|
161 | + /** |
|
162 | + * Retrieves the full names of the variables that are present in the collection. |
|
163 | + * @return string[] |
|
164 | + */ |
|
165 | 165 | public function getNames() : array |
166 | 166 | { |
167 | 167 | $result = array(); |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | return $result; |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Takes a list of variables and sorts them, throwing away |
|
184 | - * the source array's keys. |
|
185 | - * |
|
186 | - * @param Mailcode_Variables_Variable[] $entries |
|
187 | - * @return Mailcode_Variables_Variable[] |
|
188 | - */ |
|
182 | + /** |
|
183 | + * Takes a list of variables and sorts them, throwing away |
|
184 | + * the source array's keys. |
|
185 | + * |
|
186 | + * @param Mailcode_Variables_Variable[] $entries |
|
187 | + * @return Mailcode_Variables_Variable[] |
|
188 | + */ |
|
189 | 189 | protected function sortVariables(array $entries) |
190 | 190 | { |
191 | 191 | $result = array_values($entries); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | return $result; |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Merges the variables collection with the target collection |
|
203 | - * by inheriting all that collection's variables. |
|
204 | - * |
|
205 | - * @param Mailcode_Variables_Collection $collection |
|
206 | - * @return Mailcode_Variables_Collection |
|
207 | - */ |
|
201 | + /** |
|
202 | + * Merges the variables collection with the target collection |
|
203 | + * by inheriting all that collection's variables. |
|
204 | + * |
|
205 | + * @param Mailcode_Variables_Collection $collection |
|
206 | + * @return Mailcode_Variables_Collection |
|
207 | + */ |
|
208 | 208 | public function mergeWith(Mailcode_Variables_Collection $collection) : Mailcode_Variables_Collection |
209 | 209 | { |
210 | 210 | $variables = $collection->getGroupedByHash(); |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | { |
63 | 63 | $fullName = $this->fixName($fullName); |
64 | 64 | |
65 | - foreach($this->variables as $variable) |
|
65 | + foreach ($this->variables as $variable) |
|
66 | 66 | { |
67 | - if($variable->getFullName() === $fullName) |
|
67 | + if ($variable->getFullName() === $fullName) |
|
68 | 68 | { |
69 | 69 | return true; |
70 | 70 | } |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | $collection = new Mailcode_Variables_Collection_Regular(); |
89 | 89 | |
90 | - foreach($this->variables as $variable) |
|
90 | + foreach ($this->variables as $variable) |
|
91 | 91 | { |
92 | - if($variable->getFullName() === $fullName) |
|
92 | + if ($variable->getFullName() === $fullName) |
|
93 | 93 | { |
94 | 94 | $collection->add($variable); |
95 | 95 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function fixName(string $fullName) : string |
108 | 108 | { |
109 | - if(substr($fullName, 0, 1) === '$') |
|
109 | + if (substr($fullName, 0, 1) === '$') |
|
110 | 110 | { |
111 | 111 | return $fullName; |
112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $entries = array(); |
126 | 126 | |
127 | - foreach($this->variables as $variable) |
|
127 | + foreach ($this->variables as $variable) |
|
128 | 128 | { |
129 | 129 | $entries[$variable->getHash()] = $variable; |
130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | $entries = array(); |
143 | 143 | |
144 | - foreach($this->variables as $variable) |
|
144 | + foreach ($this->variables as $variable) |
|
145 | 145 | { |
146 | 146 | $entries[$variable->getFullName()] = $variable; |
147 | 147 | } |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | { |
167 | 167 | $result = array(); |
168 | 168 | |
169 | - foreach($this->variables as $variable) |
|
169 | + foreach ($this->variables as $variable) |
|
170 | 170 | { |
171 | 171 | $name = $variable->getFullName(); |
172 | 172 | |
173 | - if(!in_array($name, $result)) |
|
173 | + if (!in_array($name, $result)) |
|
174 | 174 | { |
175 | 175 | $result[] = $name; |
176 | 176 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $variables = $collection->getGroupedByHash(); |
211 | 211 | |
212 | - foreach($variables as $variable) |
|
212 | + foreach ($variables as $variable) |
|
213 | 213 | { |
214 | 214 | $this->add($variable); |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | $variables = $this->getAll(); |
223 | 223 | |
224 | - if(!empty($variables)) |
|
224 | + if (!empty($variables)) |
|
225 | 225 | { |
226 | 226 | return array_shift($variables); |
227 | 227 | } |
@@ -21,24 +21,24 @@ |
||
21 | 21 | */ |
22 | 22 | class Mailcode_Parser_Match |
23 | 23 | { |
24 | - /** |
|
25 | - * @var string |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var string |
|
26 | + */ |
|
27 | 27 | protected $name; |
28 | 28 | |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | 32 | protected $type; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | protected $params; |
38 | 38 | |
39 | - /** |
|
40 | - * @var string |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var string |
|
41 | + */ |
|
42 | 42 | protected $matchedString; |
43 | 43 | |
44 | 44 | public function __construct(string $name, string $type, string $params, string $matchedString) |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | return $this->getOperand(); |
31 | 31 | } |
32 | 32 | |
33 | - /** |
|
34 | - * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
35 | - * |
|
36 | - * @return bool |
|
37 | - */ |
|
33 | + /** |
|
34 | + * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
35 | + * |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | 38 | public function isComparator() : bool |
39 | 39 | { |
40 | 40 | return |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | $this->isSmallerOrEquals(); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
51 | - * |
|
52 | - * @return bool |
|
53 | - */ |
|
49 | + /** |
|
50 | + * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
51 | + * |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | 54 | public function isCalculator() : bool |
55 | 55 | { |
56 | 56 | return |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | public function getVariable() : Mailcode_Variables_Variable |
26 | 26 | { |
27 | - if($this->subject instanceof Mailcode_Variables_Variable) |
|
27 | + if ($this->subject instanceof Mailcode_Variables_Variable) |
|
28 | 28 | { |
29 | 29 | return $this->subject; |
30 | 30 | } |
@@ -20,26 +20,26 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class Mailcode_Parser_Statement_Tokenizer_Token |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | protected $tokenID; |
27 | 27 | |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | protected $matchedText; |
32 | 32 | |
33 | - /** |
|
34 | - * @var mixed |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var mixed |
|
35 | + */ |
|
36 | 36 | protected $subject; |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $tokenID |
|
40 | - * @param string $matchedText |
|
41 | - * @param mixed $subject |
|
42 | - */ |
|
38 | + /** |
|
39 | + * @param string $tokenID |
|
40 | + * @param string $matchedText |
|
41 | + * @param mixed $subject |
|
42 | + */ |
|
43 | 43 | public function __construct(string $tokenID, string $matchedText, $subject=null) |
44 | 44 | { |
45 | 45 | $this->tokenID = $tokenID; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * @param string $matchedText |
41 | 41 | * @param mixed $subject |
42 | 42 | */ |
43 | - public function __construct(string $tokenID, string $matchedText, $subject=null) |
|
43 | + public function __construct(string $tokenID, string $matchedText, $subject = null) |
|
44 | 44 | { |
45 | 45 | $this->tokenID = $tokenID; |
46 | 46 | $this->matchedText = $matchedText; |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $result = array(); |
136 | 136 | |
137 | - foreach($this->tokensOrdered as $token) |
|
137 | + foreach ($this->tokensOrdered as $token) |
|
138 | 138 | { |
139 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
139 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
140 | 140 | { |
141 | 141 | $result[] = $token; |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $unknown = $this->getUnknown(); |
151 | 151 | |
152 | - if(!empty($unknown)) |
|
152 | + if (!empty($unknown)) |
|
153 | 153 | { |
154 | 154 | return array_shift($unknown); |
155 | 155 | } |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | { |
162 | 162 | $parts = array(); |
163 | 163 | |
164 | - foreach($this->tokensOrdered as $token) |
|
164 | + foreach ($this->tokensOrdered as $token) |
|
165 | 165 | { |
166 | 166 | $string = $token->getNormalized(); |
167 | 167 | |
168 | - if(!empty($string)) |
|
168 | + if (!empty($string)) |
|
169 | 169 | { |
170 | 170 | $parts[] = $string; |
171 | 171 | } |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | { |
179 | 179 | $this->tokenized = trim($statement); |
180 | 180 | |
181 | - foreach($this->tokenCategories as $token) |
|
181 | + foreach ($this->tokenCategories as $token) |
|
182 | 182 | { |
183 | 183 | $method = 'tokenize_'.$token; |
184 | 184 | |
185 | - if(!method_exists($this, $method)) |
|
185 | + if (!method_exists($this, $method)) |
|
186 | 186 | { |
187 | 187 | throw new Mailcode_Exception( |
188 | 188 | 'Unknown statement token.', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param string $matchedText |
207 | 207 | * @param mixed $subject |
208 | 208 | */ |
209 | - protected function registerToken(string $type, string $matchedText, $subject=null) : void |
|
209 | + protected function registerToken(string $type, string $matchedText, $subject = null) : void |
|
210 | 210 | { |
211 | 211 | $tokenID = $this->generateID(); |
212 | 212 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | |
224 | 224 | protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token |
225 | 225 | { |
226 | - foreach($this->tokensTemporary as $token) |
|
226 | + foreach ($this->tokensTemporary as $token) |
|
227 | 227 | { |
228 | - if($token->getID() === $tokenID) |
|
228 | + if ($token->getID() === $tokenID) |
|
229 | 229 | { |
230 | 230 | return $token; |
231 | 231 | } |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | |
242 | 242 | protected function tokenize_keywords() : void |
243 | 243 | { |
244 | - foreach($this->keywords as $keyword) |
|
244 | + foreach ($this->keywords as $keyword) |
|
245 | 245 | { |
246 | - if(strstr($this->tokenized, $keyword)) |
|
246 | + if (strstr($this->tokenized, $keyword)) |
|
247 | 247 | { |
248 | 248 | $this->registerToken('Keyword', $keyword); |
249 | 249 | } |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | // over that could not be tokenized. |
258 | 258 | $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized); |
259 | 259 | |
260 | - foreach($parts as $part) |
|
260 | + foreach ($parts as $part) |
|
261 | 261 | { |
262 | 262 | $token = $this->getTokenByID($part); |
263 | 263 | |
264 | 264 | // if the entry is a token, simply add it. |
265 | - if($token) |
|
265 | + if ($token) |
|
266 | 266 | { |
267 | 267 | $this->tokensOrdered[] = $token; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash(); |
280 | 280 | |
281 | - foreach($vars as $var) |
|
281 | + foreach ($vars as $var) |
|
282 | 282 | { |
283 | 283 | $this->registerToken('Variable', $var->getMatchedText(), $var); |
284 | 284 | } |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | |
287 | 287 | protected function tokenize_operands() : void |
288 | 288 | { |
289 | - foreach($this->operands as $operand) |
|
289 | + foreach ($this->operands as $operand) |
|
290 | 290 | { |
291 | - if(strstr($this->tokenized, $operand)) |
|
291 | + if (strstr($this->tokenized, $operand)) |
|
292 | 292 | { |
293 | 293 | $this->registerToken('Operand', $operand); |
294 | 294 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $matches = array(); |
301 | 301 | preg_match_all('/"(.*)"/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
302 | 302 | |
303 | - foreach($matches[0] as $match) |
|
303 | + foreach ($matches[0] as $match) |
|
304 | 304 | { |
305 | 305 | $this->registerToken('StringLiteral', $match); |
306 | 306 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $matches = array(); |
312 | 312 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
313 | 313 | |
314 | - foreach($matches[0] as $match) |
|
314 | + foreach ($matches[0] as $match) |
|
315 | 315 | { |
316 | 316 | $this->registerToken('Number', $match); |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | static $alphas; |
330 | 330 | |
331 | - if(!isset($alphas)) |
|
331 | + if (!isset($alphas)) |
|
332 | 332 | { |
333 | 333 | $alphas = range('A', 'Z'); |
334 | 334 | } |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | |
338 | 338 | $result = ''; |
339 | 339 | |
340 | - for($i=0; $i < $amount; $i++) |
|
340 | + for ($i = 0; $i < $amount; $i++) |
|
341 | 341 | { |
342 | 342 | $result .= $alphas[array_rand($alphas)]; |
343 | 343 | } |
344 | 344 | |
345 | - if(!in_array($result, self::$ids)) |
|
345 | + if (!in_array($result, self::$ids)) |
|
346 | 346 | { |
347 | 347 | self::$ids[] = $result; |
348 | 348 | return $result; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | const ERROR_TOKENIZE_METHOD_MISSING = 49801; |
25 | 25 | |
26 | - /** |
|
27 | - * @var string[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string[] |
|
28 | + */ |
|
29 | 29 | protected $operands = array( |
30 | 30 | '==', |
31 | 31 | '<=', |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | '<' |
41 | 41 | ); |
42 | 42 | |
43 | - /** |
|
44 | - * @var string[] |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string[] |
|
45 | + */ |
|
46 | 46 | protected $keywords = array( |
47 | 47 | 'in:', |
48 | 48 | 'insensitive:' |
49 | 49 | ); |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected $delimiter = '§§'; |
55 | 55 | |
56 | 56 | /** |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | 'extract_tokens' |
67 | 67 | ); |
68 | 68 | |
69 | - /** |
|
70 | - * @var Mailcode_Parser_Statement |
|
71 | - */ |
|
69 | + /** |
|
70 | + * @var Mailcode_Parser_Statement |
|
71 | + */ |
|
72 | 72 | protected $statement; |
73 | 73 | |
74 | - /** |
|
75 | - * @var string |
|
76 | - */ |
|
74 | + /** |
|
75 | + * @var string |
|
76 | + */ |
|
77 | 77 | protected $tokenized; |
78 | 78 | |
79 | - /** |
|
80 | - * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
81 | - */ |
|
79 | + /** |
|
80 | + * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
81 | + */ |
|
82 | 82 | protected $tokensTemporary = array(); |
83 | 83 | |
84 | 84 | /** |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected $tokensOrdered = array(); |
88 | 88 | |
89 | - /** |
|
90 | - * @var string[] |
|
91 | - */ |
|
89 | + /** |
|
90 | + * @var string[] |
|
91 | + */ |
|
92 | 92 | protected static $ids = array(); |
93 | 93 | |
94 | 94 | public function __construct(Mailcode_Parser_Statement $statement) |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | $this->tokenize($statement->getStatementString()); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Retrieves all tokens detected in the statement string, in |
|
103 | - * the order they were found. |
|
104 | - * |
|
105 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
106 | - */ |
|
101 | + /** |
|
102 | + * Retrieves all tokens detected in the statement string, in |
|
103 | + * the order they were found. |
|
104 | + * |
|
105 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
106 | + */ |
|
107 | 107 | public function getTokens() |
108 | 108 | { |
109 | 109 | return $this->tokensOrdered; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | return !empty($this->tokensOrdered); |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Whether there were any unknown tokens in the statement. |
|
119 | - * |
|
120 | - * @return bool |
|
121 | - */ |
|
117 | + /** |
|
118 | + * Whether there were any unknown tokens in the statement. |
|
119 | + * |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | 122 | public function hasUnknown() : bool |
123 | 123 | { |
124 | 124 | $unknown = $this->getUnknown(); |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | return !empty($unknown); |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Retrieves all unknown content tokens, if any. |
|
131 | - * |
|
132 | - * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
133 | - */ |
|
129 | + /** |
|
130 | + * Retrieves all unknown content tokens, if any. |
|
131 | + * |
|
132 | + * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
133 | + */ |
|
134 | 134 | public function getUnknown() |
135 | 135 | { |
136 | 136 | $result = array(); |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - /** |
|
204 | - * Registers a token to add in the statement string. |
|
205 | - * |
|
206 | - * @param string $type |
|
207 | - * @param string $matchedText |
|
208 | - * @param mixed $subject |
|
209 | - */ |
|
203 | + /** |
|
204 | + * Registers a token to add in the statement string. |
|
205 | + * |
|
206 | + * @param string $type |
|
207 | + * @param string $matchedText |
|
208 | + * @param mixed $subject |
|
209 | + */ |
|
210 | 210 | protected function registerToken(string $type, string $matchedText, $subject=null) : void |
211 | 211 | { |
212 | 212 | $tokenID = $this->generateID(); |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - /** |
|
322 | - * Generates a unique alphabet-based ID without numbers |
|
323 | - * to use as token name, to avoid conflicts with the |
|
324 | - * numbers detection. |
|
325 | - * |
|
326 | - * @return string |
|
327 | - */ |
|
321 | + /** |
|
322 | + * Generates a unique alphabet-based ID without numbers |
|
323 | + * to use as token name, to avoid conflicts with the |
|
324 | + * numbers detection. |
|
325 | + * |
|
326 | + * @return string |
|
327 | + */ |
|
328 | 328 | protected function generateID() : string |
329 | 329 | { |
330 | 330 | static $alphas; |