@@ -38,38 +38,38 @@ |
||
38 | 38 | */ |
39 | 39 | protected $text; |
40 | 40 | |
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | 44 | protected $trimmed; |
45 | 45 | |
46 | - /** |
|
47 | - * @var int |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var int |
|
48 | + */ |
|
49 | 49 | protected $lineNumber; |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected $type; |
55 | 55 | |
56 | - /** |
|
57 | - * @var string |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var string |
|
58 | + */ |
|
59 | 59 | protected $varName = ''; |
60 | 60 | |
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | 64 | protected $varValue = ''; |
65 | 65 | |
66 | 66 | protected $valueUnquoted = ''; |
67 | 67 | |
68 | 68 | protected $quoteStyle = ''; |
69 | 69 | |
70 | - /** |
|
71 | - * @var string |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var string |
|
72 | + */ |
|
73 | 73 | protected $sectionName = ''; |
74 | 74 | |
75 | 75 | public function __construct(string $text, int $lineNumber) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $this->trimmed = trim($text); |
79 | 79 | $this->lineNumber = $lineNumber; |
80 | 80 | |
81 | - if(empty($this->trimmed)) |
|
81 | + if (empty($this->trimmed)) |
|
82 | 82 | { |
83 | 83 | $this->type = self::TYPE_EMPTY; |
84 | 84 | return; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | $startChar = substr($this->trimmed, 0, 1); |
88 | 88 | |
89 | - if($startChar === ';') |
|
89 | + if ($startChar === ';') |
|
90 | 90 | { |
91 | 91 | $this->type = self::TYPE_COMMENT; |
92 | 92 | } |
93 | - else if($startChar === '[') |
|
93 | + else if ($startChar === '[') |
|
94 | 94 | { |
95 | 95 | $this->type = self::TYPE_SECTION_DECLARATION; |
96 | 96 | $this->sectionName = trim($this->trimmed, '[]'); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | else |
100 | 100 | { |
101 | 101 | $pos = strpos($this->trimmed, '='); |
102 | - if($pos === false) |
|
102 | + if ($pos === false) |
|
103 | 103 | { |
104 | 104 | $this->type = self::TYPE_INVALID; |
105 | 105 | return; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->type = self::TYPE_VALUE; |
109 | 109 | $this->varName = trim(substr($this->trimmed, 0, $pos)); |
110 | 110 | |
111 | - $this->parseValue(substr($this->trimmed, $pos+1)); |
|
111 | + $this->parseValue(substr($this->trimmed, $pos + 1)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | |
119 | 119 | $value = $this->varValue; |
120 | 120 | |
121 | - if(substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"') |
|
121 | + if (substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"') |
|
122 | 122 | { |
123 | 123 | $value = trim($value, '"'); |
124 | 124 | $this->quoteStyle = '"'; |
125 | 125 | } |
126 | - else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
126 | + else if (substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
127 | 127 | { |
128 | 128 | $value = trim($value, "'"); |
129 | 129 | $this->quoteStyle = "'"; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | public function getQuotedVarValue() : string |
146 | 146 | { |
147 | - if($this->quoteStyle === '') { |
|
147 | + if ($this->quoteStyle === '') { |
|
148 | 148 | return $this->getVarValue(); |
149 | 149 | } |
150 | 150 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | public function setValue($value) : IniHelper_Line |
200 | 200 | { |
201 | - if(!is_scalar($value)) |
|
201 | + if (!is_scalar($value)) |
|
202 | 202 | { |
203 | 203 | throw new IniHelper_Exception( |
204 | 204 | 'Cannot use non-scalar values.', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | public function toString() : string |
220 | 220 | { |
221 | - switch($this->type) |
|
221 | + switch ($this->type) |
|
222 | 222 | { |
223 | 223 | case self::TYPE_EMPTY: |
224 | 224 | case self::TYPE_INVALID: |
@@ -89,14 +89,12 @@ discard block |
||
89 | 89 | if($startChar === ';') |
90 | 90 | { |
91 | 91 | $this->type = self::TYPE_COMMENT; |
92 | - } |
|
93 | - else if($startChar === '[') |
|
92 | + } else if($startChar === '[') |
|
94 | 93 | { |
95 | 94 | $this->type = self::TYPE_SECTION_DECLARATION; |
96 | 95 | $this->sectionName = trim($this->trimmed, '[]'); |
97 | 96 | $this->sectionName = trim($this->sectionName); // remove any whitespace |
98 | - } |
|
99 | - else |
|
97 | + } else |
|
100 | 98 | { |
101 | 99 | $pos = strpos($this->trimmed, '='); |
102 | 100 | if($pos === false) |
@@ -122,8 +120,7 @@ discard block |
||
122 | 120 | { |
123 | 121 | $value = trim($value, '"'); |
124 | 122 | $this->quoteStyle = '"'; |
125 | - } |
|
126 | - else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
123 | + } else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
127 | 124 | { |
128 | 125 | $value = trim($value, "'"); |
129 | 126 | $this->quoteStyle = "'"; |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class IniHelper_Section |
23 | 23 | { |
24 | - /** |
|
25 | - * @var IniHelper |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var IniHelper |
|
26 | + */ |
|
27 | 27 | protected $ini; |
28 | 28 | |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | 32 | protected $name; |
33 | 33 | |
34 | - /** |
|
35 | - * @var IniHelper_Line[] |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var IniHelper_Line[] |
|
36 | + */ |
|
37 | 37 | protected $lines = array(); |
38 | 38 | |
39 | 39 | public function __construct(IniHelper $ini, string $name) |
@@ -42,33 +42,33 @@ discard block |
||
42 | 42 | $this->name = $name; |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * The section's name. |
|
47 | - * @return string |
|
48 | - */ |
|
45 | + /** |
|
46 | + * The section's name. |
|
47 | + * @return string |
|
48 | + */ |
|
49 | 49 | public function getName() : string |
50 | 50 | { |
51 | 51 | return $this->name; |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Whether this is the default section: this |
|
56 | - * is used internally to store all variables that |
|
57 | - * are not in any specific section. |
|
58 | - * |
|
59 | - * @return bool |
|
60 | - */ |
|
54 | + /** |
|
55 | + * Whether this is the default section: this |
|
56 | + * is used internally to store all variables that |
|
57 | + * are not in any specific section. |
|
58 | + * |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | 61 | public function isDefault() : bool |
62 | 62 | { |
63 | 63 | return $this->name === IniHelper::SECTION_DEFAULT; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Adds a line instance to the section. |
|
68 | - * |
|
69 | - * @param IniHelper_Line $line |
|
70 | - * @return IniHelper_Section |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Adds a line instance to the section. |
|
68 | + * |
|
69 | + * @param IniHelper_Line $line |
|
70 | + * @return IniHelper_Section |
|
71 | + */ |
|
72 | 72 | public function addLine(IniHelper_Line $line) : IniHelper_Section |
73 | 73 | { |
74 | 74 | $this->lines[] = $line; |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Converts the values contained in the section into |
|
81 | - * an associative array. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
79 | + /** |
|
80 | + * Converts the values contained in the section into |
|
81 | + * an associative array. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | 85 | public function toArray() : array |
86 | 86 | { |
87 | 87 | $result = array(); |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | return $result; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Converts the section's lines into an INI string. |
|
119 | - * |
|
120 | - * @return string |
|
121 | - */ |
|
117 | + /** |
|
118 | + * Converts the section's lines into an INI string. |
|
119 | + * |
|
120 | + * @return string |
|
121 | + */ |
|
122 | 122 | public function toString() |
123 | 123 | { |
124 | 124 | $lines = array(); |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | return implode($this->ini->getEOLChar(), $lines); |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Deletes a line from the section. |
|
145 | - * |
|
146 | - * @param IniHelper_Line $toDelete |
|
147 | - * @return IniHelper_Section |
|
148 | - */ |
|
143 | + /** |
|
144 | + * Deletes a line from the section. |
|
145 | + * |
|
146 | + * @param IniHelper_Line $toDelete |
|
147 | + * @return IniHelper_Section |
|
148 | + */ |
|
149 | 149 | public function deleteLine(IniHelper_Line $toDelete) : IniHelper_Section |
150 | 150 | { |
151 | 151 | $keep = array(); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Sets the value of a variable, overwriting any existing value. |
|
167 | - * |
|
168 | - * @param string $name |
|
169 | - * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
170 | - * @return IniHelper_Section |
|
171 | - */ |
|
165 | + /** |
|
166 | + * Sets the value of a variable, overwriting any existing value. |
|
167 | + * |
|
168 | + * @param string $name |
|
169 | + * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
170 | + * @return IniHelper_Section |
|
171 | + */ |
|
172 | 172 | public function setValue(string $name, $value) : IniHelper_Section |
173 | 173 | { |
174 | 174 | $lines = $this->getLinesByVariable($name); |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | return $this; |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Adds a variable value to the section. Unlike setValue(), this |
|
234 | - * will not overwrite any existing value. If the name is an existing |
|
235 | - * variable name, it will be converted to duplicate keys. |
|
236 | - * |
|
237 | - * @param string $name |
|
238 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
239 | - * @return IniHelper_Section |
|
240 | - */ |
|
232 | + /** |
|
233 | + * Adds a variable value to the section. Unlike setValue(), this |
|
234 | + * will not overwrite any existing value. If the name is an existing |
|
235 | + * variable name, it will be converted to duplicate keys. |
|
236 | + * |
|
237 | + * @param string $name |
|
238 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
239 | + * @return IniHelper_Section |
|
240 | + */ |
|
241 | 241 | public function addValue(string $name, $value) : IniHelper_Section |
242 | 242 | { |
243 | 243 | // array value? Treat it as duplicate keys. |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | |
298 | - /** |
|
299 | - * Retrieves all lines for the specified variable name. |
|
300 | - * |
|
301 | - * @param string $name |
|
302 | - * @return \AppUtils\IniHelper_Line[] |
|
303 | - */ |
|
298 | + /** |
|
299 | + * Retrieves all lines for the specified variable name. |
|
300 | + * |
|
301 | + * @param string $name |
|
302 | + * @return \AppUtils\IniHelper_Line[] |
|
303 | + */ |
|
304 | 304 | public function getLinesByVariable(string $name) |
305 | 305 | { |
306 | 306 | $result = array(); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | { |
87 | 87 | $result = array(); |
88 | 88 | |
89 | - foreach($this->lines as $line) |
|
89 | + foreach ($this->lines as $line) |
|
90 | 90 | { |
91 | - if(!$line->isValue()) { |
|
91 | + if (!$line->isValue()) { |
|
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $name = $line->getVarName(); |
96 | 96 | |
97 | - if(!isset($result[$name])) |
|
97 | + if (!isset($result[$name])) |
|
98 | 98 | { |
99 | 99 | $result[$name] = $line->getVarValue(); |
100 | 100 | continue; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // name exists in collection? Then this is a |
104 | 104 | // duplicate key and we need to convert it to |
105 | 105 | // an indexed array of values. |
106 | - if(!is_array($result[$name])) |
|
106 | + if (!is_array($result[$name])) |
|
107 | 107 | { |
108 | 108 | $result[$name] = array($result[$name]); |
109 | 109 | } |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | public function toString() |
123 | 123 | { |
124 | 124 | $lines = array(); |
125 | - if(!$this->isDefault()) |
|
125 | + if (!$this->isDefault()) |
|
126 | 126 | { |
127 | 127 | $lines[] = '['.$this->getName().']'; |
128 | 128 | } |
129 | 129 | |
130 | - foreach($this->lines as $line) |
|
130 | + foreach ($this->lines as $line) |
|
131 | 131 | { |
132 | 132 | // we already did this |
133 | - if($line->isSection()) { |
|
133 | + if ($line->isSection()) { |
|
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | { |
151 | 151 | $keep = array(); |
152 | 152 | |
153 | - foreach($this->lines as $line) |
|
153 | + foreach ($this->lines as $line) |
|
154 | 154 | { |
155 | - if($line !== $toDelete) { |
|
155 | + if ($line !== $toDelete) { |
|
156 | 156 | $keep[] = $line; |
157 | 157 | } |
158 | 158 | } |
@@ -177,23 +177,23 @@ discard block |
||
177 | 177 | // Removes any superfluous values that may |
178 | 178 | // already exist, if there are more than the |
179 | 179 | // new set of values. |
180 | - if(is_array($value)) |
|
180 | + if (is_array($value)) |
|
181 | 181 | { |
182 | 182 | $values = array_values($value); |
183 | 183 | $amountNew = count($values); |
184 | 184 | $amountExisting = count($lines); |
185 | 185 | |
186 | 186 | $max = $amountNew; |
187 | - if($amountExisting > $max) { |
|
187 | + if ($amountExisting > $max) { |
|
188 | 188 | $max = $amountExisting; |
189 | 189 | } |
190 | 190 | |
191 | - for($i=0; $i < $max; $i++) |
|
191 | + for ($i = 0; $i < $max; $i++) |
|
192 | 192 | { |
193 | 193 | // new value exists |
194 | - if(isset($values[$i])) |
|
194 | + if (isset($values[$i])) |
|
195 | 195 | { |
196 | - if(isset($lines[$i])) { |
|
196 | + if (isset($lines[$i])) { |
|
197 | 197 | $lines[$i]->setValue($values[$i]); |
198 | 198 | } else { |
199 | 199 | $this->addValueLine($name, $values[$i]); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | else |
212 | 212 | { |
213 | 213 | // remove all superfluous lines |
214 | - if(!empty($lines)) |
|
214 | + if (!empty($lines)) |
|
215 | 215 | { |
216 | 216 | $line = array_shift($lines); // keep only the first line |
217 | 217 | $line->setValue($value); |
218 | 218 | |
219 | - foreach($lines as $delete) { |
|
219 | + foreach ($lines as $delete) { |
|
220 | 220 | $this->deleteLine($delete); |
221 | 221 | } |
222 | 222 | } |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | public function addValue(string $name, $value) : IniHelper_Section |
242 | 242 | { |
243 | 243 | // array value? Treat it as duplicate keys. |
244 | - if(is_array($value)) |
|
244 | + if (is_array($value)) |
|
245 | 245 | { |
246 | 246 | $values = array_values($value); |
247 | 247 | |
248 | - foreach($values as $setValue) |
|
248 | + foreach ($values as $setValue) |
|
249 | 249 | { |
250 | 250 | $this->addValue($name, $setValue); |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | $lines = $this->getLinesByVariable($name); |
257 | 257 | |
258 | - if(empty($lines)) |
|
258 | + if (empty($lines)) |
|
259 | 259 | { |
260 | 260 | $this->addValueLine($name, $value); |
261 | 261 | } |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | { |
264 | 264 | $found = false; |
265 | 265 | |
266 | - foreach($lines as $line) |
|
266 | + foreach ($lines as $line) |
|
267 | 267 | { |
268 | - if($line->getVarValue() === $value) { |
|
268 | + if ($line->getVarValue() === $value) { |
|
269 | 269 | $found = $line; |
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - if(!$found) |
|
274 | + if (!$found) |
|
275 | 275 | { |
276 | 276 | $this->addValueLine($name, $value); |
277 | 277 | } |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | { |
306 | 306 | $result = array(); |
307 | 307 | |
308 | - foreach($this->lines as $line) |
|
308 | + foreach ($this->lines as $line) |
|
309 | 309 | { |
310 | - if($line->isValue() && $line->getVarName() === $name) { |
|
310 | + if ($line->isValue() && $line->getVarName() === $name) { |
|
311 | 311 | $result[] = $line; |
312 | 312 | } |
313 | 313 | } |
@@ -198,8 +198,7 @@ discard block |
||
198 | 198 | } else { |
199 | 199 | $this->addValueLine($name, $values[$i]); |
200 | 200 | } |
201 | - } |
|
202 | - else |
|
201 | + } else |
|
203 | 202 | { |
204 | 203 | $this->deleteLine($lines[$i]); |
205 | 204 | } |
@@ -219,8 +218,7 @@ discard block |
||
219 | 218 | foreach($lines as $delete) { |
220 | 219 | $this->deleteLine($delete); |
221 | 220 | } |
222 | - } |
|
223 | - else |
|
221 | + } else |
|
224 | 222 | { |
225 | 223 | $this->addValueLine($name, $value); |
226 | 224 | } |
@@ -258,8 +256,7 @@ discard block |
||
258 | 256 | if(empty($lines)) |
259 | 257 | { |
260 | 258 | $this->addValueLine($name, $value); |
261 | - } |
|
262 | - else |
|
259 | + } else |
|
263 | 260 | { |
264 | 261 | $found = false; |
265 | 262 |
@@ -443,12 +443,10 @@ discard block |
||
443 | 443 | if($this->isFragment === true) |
444 | 444 | { |
445 | 445 | return '#'.$this->getFragment(); |
446 | - } |
|
447 | - else if($this->isPhone === true) |
|
446 | + } else if($this->isPhone === true) |
|
448 | 447 | { |
449 | 448 | return 'tel://'.$this->getHost(); |
450 | - } |
|
451 | - else if($this->isEmail === true) |
|
449 | + } else if($this->isEmail === true) |
|
452 | 450 | { |
453 | 451 | return 'mailto:'.$this->getPath(); |
454 | 452 | } |
@@ -598,13 +596,11 @@ discard block |
||
598 | 596 | $tooltip, |
599 | 597 | $parts |
600 | 598 | ); |
601 | - } |
|
602 | - else |
|
599 | + } else |
|
603 | 600 | { |
604 | 601 | continue; |
605 | 602 | } |
606 | - } |
|
607 | - else |
|
603 | + } else |
|
608 | 604 | { |
609 | 605 | $tag = sprintf( |
610 | 606 | '<span class="link-param">%s</span>', |
@@ -38,40 +38,40 @@ discard block |
||
38 | 38 | const TYPE_PHONE = 'phone'; |
39 | 39 | const TYPE_URL = 'url'; |
40 | 40 | |
41 | - /** |
|
42 | - * The original URL that was passed to the constructor. |
|
43 | - * @var string |
|
44 | - */ |
|
41 | + /** |
|
42 | + * The original URL that was passed to the constructor. |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $rawURL; |
46 | 46 | |
47 | - /** |
|
48 | - * @var array |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var array |
|
49 | + */ |
|
50 | 50 | protected $info; |
51 | 51 | |
52 | - /** |
|
53 | - * @var bool |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var bool |
|
54 | + */ |
|
55 | 55 | protected $isEmail = false; |
56 | 56 | |
57 | - /** |
|
58 | - * @var bool |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var bool |
|
59 | + */ |
|
60 | 60 | protected $isFragment = false; |
61 | 61 | |
62 | - /** |
|
63 | - * @var bool |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var bool |
|
64 | + */ |
|
65 | 65 | protected $isValid = true; |
66 | 66 | |
67 | - /** |
|
68 | - * @var bool |
|
69 | - */ |
|
67 | + /** |
|
68 | + * @var bool |
|
69 | + */ |
|
70 | 70 | protected $isPhone = false; |
71 | 71 | |
72 | - /** |
|
73 | - * @var array |
|
74 | - */ |
|
72 | + /** |
|
73 | + * @var array |
|
74 | + */ |
|
75 | 75 | protected $knownSchemes = array( |
76 | 76 | 'ftp', |
77 | 77 | 'http', |
@@ -82,41 +82,41 @@ discard block |
||
82 | 82 | 'file' |
83 | 83 | ); |
84 | 84 | |
85 | - /** |
|
86 | - * @var array |
|
87 | - */ |
|
85 | + /** |
|
86 | + * @var array |
|
87 | + */ |
|
88 | 88 | protected $error; |
89 | 89 | |
90 | - /** |
|
91 | - * @var array |
|
92 | - */ |
|
90 | + /** |
|
91 | + * @var array |
|
92 | + */ |
|
93 | 93 | protected $params = array(); |
94 | 94 | |
95 | - /** |
|
96 | - * @var string[] |
|
97 | - */ |
|
95 | + /** |
|
96 | + * @var string[] |
|
97 | + */ |
|
98 | 98 | protected $excludedParams = array(); |
99 | 99 | |
100 | - /** |
|
101 | - * @var bool |
|
102 | - * @see URLInfo::setParamExclusion() |
|
103 | - */ |
|
100 | + /** |
|
101 | + * @var bool |
|
102 | + * @see URLInfo::setParamExclusion() |
|
103 | + */ |
|
104 | 104 | protected $paramExclusion = false; |
105 | 105 | |
106 | - /** |
|
107 | - * @var array |
|
108 | - * @see URLInfo::getTypeLabel() |
|
109 | - */ |
|
106 | + /** |
|
107 | + * @var array |
|
108 | + * @see URLInfo::getTypeLabel() |
|
109 | + */ |
|
110 | 110 | protected static $typeLabels; |
111 | 111 | |
112 | - /** |
|
113 | - * @var bool |
|
114 | - */ |
|
112 | + /** |
|
113 | + * @var bool |
|
114 | + */ |
|
115 | 115 | protected $highlightExcluded = false; |
116 | 116 | |
117 | - /** |
|
118 | - * @var array |
|
119 | - */ |
|
117 | + /** |
|
118 | + * @var array |
|
119 | + */ |
|
120 | 120 | protected $infoKeys = array( |
121 | 121 | 'scheme', |
122 | 122 | 'host', |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | 'fragment' |
129 | 129 | ); |
130 | 130 | |
131 | - /** |
|
132 | - * @var string |
|
133 | - */ |
|
131 | + /** |
|
132 | + * @var string |
|
133 | + */ |
|
134 | 134 | protected $url; |
135 | 135 | |
136 | 136 | public function __construct(string $url) |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | $this->isValid = true; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Filters an URL: removes control characters and the |
|
221 | - * like to have a clean URL to work with. |
|
222 | - * |
|
223 | - * @param string $url |
|
224 | - * @return string |
|
225 | - */ |
|
219 | + /** |
|
220 | + * Filters an URL: removes control characters and the |
|
221 | + * like to have a clean URL to work with. |
|
222 | + * |
|
223 | + * @param string $url |
|
224 | + * @return string |
|
225 | + */ |
|
226 | 226 | public static function filterURL(string $url) |
227 | 227 | { |
228 | 228 | // fix ampersands if it comes from HTML |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | return $url; |
246 | 246 | } |
247 | 247 | |
248 | - /** |
|
249 | - * Goes through all information in the parse_url result |
|
250 | - * array, and attempts to fix any user errors in formatting |
|
251 | - * that can be recovered from, mostly regarding stray spaces. |
|
252 | - */ |
|
248 | + /** |
|
249 | + * Goes through all information in the parse_url result |
|
250 | + * array, and attempts to fix any user errors in formatting |
|
251 | + * that can be recovered from, mostly regarding stray spaces. |
|
252 | + */ |
|
253 | 253 | protected function filterParsed() |
254 | 254 | { |
255 | 255 | foreach($this->info as $key => $val) |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | return $this->isPhone; |
334 | 334 | } |
335 | 335 | |
336 | - /** |
|
337 | - * Whether the URL is a regular URL, not one of the |
|
338 | - * other types like a phone number or email address. |
|
339 | - * |
|
340 | - * @return bool |
|
341 | - */ |
|
336 | + /** |
|
337 | + * Whether the URL is a regular URL, not one of the |
|
338 | + * other types like a phone number or email address. |
|
339 | + * |
|
340 | + * @return bool |
|
341 | + */ |
|
342 | 342 | public function isURL() : bool |
343 | 343 | { |
344 | 344 | $host = $this->getHost(); |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | return $this->isValid; |
351 | 351 | } |
352 | 352 | |
353 | - /** |
|
354 | - * Retrieves the host name, or an empty string if none is present. |
|
355 | - * |
|
356 | - * @return string |
|
357 | - */ |
|
353 | + /** |
|
354 | + * Retrieves the host name, or an empty string if none is present. |
|
355 | + * |
|
356 | + * @return string |
|
357 | + */ |
|
358 | 358 | public function getHost() : string |
359 | 359 | { |
360 | 360 | return $this->getInfoKey('host'); |
361 | 361 | } |
362 | 362 | |
363 | - /** |
|
364 | - * Retrieves the path, or an empty string if none is present. |
|
365 | - * @return string |
|
366 | - */ |
|
363 | + /** |
|
364 | + * Retrieves the path, or an empty string if none is present. |
|
365 | + * @return string |
|
366 | + */ |
|
367 | 367 | public function getPath() : string |
368 | 368 | { |
369 | 369 | return $this->getInfoKey('path'); |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | return $this->getInfoKey('scheme'); |
380 | 380 | } |
381 | 381 | |
382 | - /** |
|
383 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
384 | - * @return int |
|
385 | - */ |
|
382 | + /** |
|
383 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
384 | + * @return int |
|
385 | + */ |
|
386 | 386 | public function getPort() : int |
387 | 387 | { |
388 | 388 | $port = $this->getInfoKey('port'); |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | return -1; |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Retrieves the raw query string, or an empty string if none is present. |
|
398 | - * |
|
399 | - * @return string |
|
400 | - * |
|
401 | - * @see URLInfo::getParams() |
|
402 | - */ |
|
396 | + /** |
|
397 | + * Retrieves the raw query string, or an empty string if none is present. |
|
398 | + * |
|
399 | + * @return string |
|
400 | + * |
|
401 | + * @see URLInfo::getParams() |
|
402 | + */ |
|
403 | 403 | public function getQuery() : string |
404 | 404 | { |
405 | 405 | return $this->getInfoKey('query'); |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | return $this->getInfoKey('pass'); |
416 | 416 | } |
417 | 417 | |
418 | - /** |
|
419 | - * Whether the URL contains a port number. |
|
420 | - * @return bool |
|
421 | - */ |
|
418 | + /** |
|
419 | + * Whether the URL contains a port number. |
|
420 | + * @return bool |
|
421 | + */ |
|
422 | 422 | public function hasPort() : bool |
423 | 423 | { |
424 | 424 | return $this->getPort() !== -1; |
425 | 425 | } |
426 | 426 | |
427 | - /** |
|
428 | - * Alias for the hasParams() method. |
|
429 | - * @return bool |
|
430 | - * @see URLInfo::hasParams() |
|
431 | - */ |
|
427 | + /** |
|
428 | + * Alias for the hasParams() method. |
|
429 | + * @return bool |
|
430 | + * @see URLInfo::hasParams() |
|
431 | + */ |
|
432 | 432 | public function hasQuery() : bool |
433 | 433 | { |
434 | 434 | return $this->hasParams(); |
@@ -509,25 +509,25 @@ discard block |
||
509 | 509 | return $normalized; |
510 | 510 | } |
511 | 511 | |
512 | - /** |
|
513 | - * Creates a hash of the URL, which can be used for comparisons. |
|
514 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
515 | - * the same links with a different parameter order will have the |
|
516 | - * same hash. |
|
517 | - * |
|
518 | - * @return string |
|
519 | - */ |
|
512 | + /** |
|
513 | + * Creates a hash of the URL, which can be used for comparisons. |
|
514 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
515 | + * the same links with a different parameter order will have the |
|
516 | + * same hash. |
|
517 | + * |
|
518 | + * @return string |
|
519 | + */ |
|
520 | 520 | public function getHash() |
521 | 521 | { |
522 | 522 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
523 | 523 | } |
524 | 524 | |
525 | - /** |
|
526 | - * Highlights the URL using HTML tags with specific highlighting |
|
527 | - * class names. |
|
528 | - * |
|
529 | - * @return string Will return an empty string if the URL is not valid. |
|
530 | - */ |
|
525 | + /** |
|
526 | + * Highlights the URL using HTML tags with specific highlighting |
|
527 | + * class names. |
|
528 | + * |
|
529 | + * @return string Will return an empty string if the URL is not valid. |
|
530 | + */ |
|
531 | 531 | public function getHighlighted() : string |
532 | 532 | { |
533 | 533 | if(!$this->isValid) { |
@@ -711,15 +711,15 @@ discard block |
||
711 | 711 | return count($params); |
712 | 712 | } |
713 | 713 | |
714 | - /** |
|
715 | - * Retrieves all parameters specified in the url, |
|
716 | - * if any, as an associative array. |
|
717 | - * |
|
718 | - * NOTE: Ignores parameters that have been added |
|
719 | - * to the excluded parameters list. |
|
720 | - * |
|
721 | - * @return array |
|
722 | - */ |
|
714 | + /** |
|
715 | + * Retrieves all parameters specified in the url, |
|
716 | + * if any, as an associative array. |
|
717 | + * |
|
718 | + * NOTE: Ignores parameters that have been added |
|
719 | + * to the excluded parameters list. |
|
720 | + * |
|
721 | + * @return array |
|
722 | + */ |
|
723 | 723 | public function getParams() : array |
724 | 724 | { |
725 | 725 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -736,22 +736,22 @@ discard block |
||
736 | 736 | return $keep; |
737 | 737 | } |
738 | 738 | |
739 | - /** |
|
740 | - * Retrieves the names of all parameters present in the URL, if any. |
|
741 | - * @return string[] |
|
742 | - */ |
|
739 | + /** |
|
740 | + * Retrieves the names of all parameters present in the URL, if any. |
|
741 | + * @return string[] |
|
742 | + */ |
|
743 | 743 | public function getParamNames() : array |
744 | 744 | { |
745 | 745 | $params = $this->getParams(); |
746 | 746 | return array_keys($params); |
747 | 747 | } |
748 | 748 | |
749 | - /** |
|
750 | - * Retrieves a specific parameter value from the URL. |
|
751 | - * |
|
752 | - * @param string $name |
|
753 | - * @return string The parameter value, or an empty string if it does not exist. |
|
754 | - */ |
|
749 | + /** |
|
750 | + * Retrieves a specific parameter value from the URL. |
|
751 | + * |
|
752 | + * @param string $name |
|
753 | + * @return string The parameter value, or an empty string if it does not exist. |
|
754 | + */ |
|
755 | 755 | public function getParam(string $name) : string |
756 | 756 | { |
757 | 757 | if(isset($this->params[$name])) { |
@@ -761,16 +761,16 @@ discard block |
||
761 | 761 | return ''; |
762 | 762 | } |
763 | 763 | |
764 | - /** |
|
765 | - * Excludes an URL parameter entirely if present: |
|
766 | - * the parser will act as if the parameter was not |
|
767 | - * even present in the source URL, effectively |
|
768 | - * stripping it. |
|
769 | - * |
|
770 | - * @param string $name |
|
771 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
772 | - * @return URLInfo |
|
773 | - */ |
|
764 | + /** |
|
765 | + * Excludes an URL parameter entirely if present: |
|
766 | + * the parser will act as if the parameter was not |
|
767 | + * even present in the source URL, effectively |
|
768 | + * stripping it. |
|
769 | + * |
|
770 | + * @param string $name |
|
771 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
772 | + * @return URLInfo |
|
773 | + */ |
|
774 | 774 | public function excludeParam(string $name, string $reason) : URLInfo |
775 | 775 | { |
776 | 776 | if(!isset($this->excludedParams[$name])) |
@@ -835,25 +835,25 @@ discard block |
||
835 | 835 | return self::$typeLabels[$this->getType()]; |
836 | 836 | } |
837 | 837 | |
838 | - /** |
|
839 | - * Whether excluded parameters should be highlighted in |
|
840 | - * a different color in the URL when using the |
|
841 | - * {@link URLInfo::getHighlighted()} method. |
|
842 | - * |
|
843 | - * @param bool $highlight |
|
844 | - * @return URLInfo |
|
845 | - */ |
|
838 | + /** |
|
839 | + * Whether excluded parameters should be highlighted in |
|
840 | + * a different color in the URL when using the |
|
841 | + * {@link URLInfo::getHighlighted()} method. |
|
842 | + * |
|
843 | + * @param bool $highlight |
|
844 | + * @return URLInfo |
|
845 | + */ |
|
846 | 846 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
847 | 847 | { |
848 | 848 | $this->highlightExcluded = $highlight; |
849 | 849 | return $this; |
850 | 850 | } |
851 | 851 | |
852 | - /** |
|
853 | - * Returns an array with all relevant URL information. |
|
854 | - * |
|
855 | - * @return array |
|
856 | - */ |
|
852 | + /** |
|
853 | + * Returns an array with all relevant URL information. |
|
854 | + * |
|
855 | + * @return array |
|
856 | + */ |
|
857 | 857 | public function toArray() : array |
858 | 858 | { |
859 | 859 | return array( |
@@ -897,24 +897,24 @@ discard block |
||
897 | 897 | return $this; |
898 | 898 | } |
899 | 899 | |
900 | - /** |
|
901 | - * Whether the parameter exclusion mode is enabled: |
|
902 | - * In this case, if any parameters have been added to the |
|
903 | - * exclusion list, all relevant methods will exclude these. |
|
904 | - * |
|
905 | - * @return bool |
|
906 | - */ |
|
900 | + /** |
|
901 | + * Whether the parameter exclusion mode is enabled: |
|
902 | + * In this case, if any parameters have been added to the |
|
903 | + * exclusion list, all relevant methods will exclude these. |
|
904 | + * |
|
905 | + * @return bool |
|
906 | + */ |
|
907 | 907 | public function isParamExclusionEnabled() : bool |
908 | 908 | { |
909 | 909 | return $this->paramExclusion; |
910 | 910 | } |
911 | 911 | |
912 | - /** |
|
913 | - * Checks whether the link contains any parameters that |
|
914 | - * are on the list of excluded parameters. |
|
915 | - * |
|
916 | - * @return bool |
|
917 | - */ |
|
912 | + /** |
|
913 | + * Checks whether the link contains any parameters that |
|
914 | + * are on the list of excluded parameters. |
|
915 | + * |
|
916 | + * @return bool |
|
917 | + */ |
|
918 | 918 | public function containsExcludedParams() : bool |
919 | 919 | { |
920 | 920 | if(empty($this->excludedParams)) { |
@@ -156,26 +156,26 @@ discard block |
||
156 | 156 | |
157 | 157 | $this->filterParsed(); |
158 | 158 | |
159 | - if($this->detectEmail()) { |
|
159 | + if ($this->detectEmail()) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | - if($this->detectFragmentLink()) { |
|
163 | + if ($this->detectFragmentLink()) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | - if($this->detectPhoneLink()) { |
|
167 | + if ($this->detectPhoneLink()) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if(!$this->isValid) { |
|
171 | + if (!$this->isValid) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // no scheme found: it may be an email address without the mailto: |
176 | 176 | // It can't be a variable, since without the scheme it would already |
177 | 177 | // have been recognized as a vaiable only link. |
178 | - if(!isset($this->info['scheme'])) { |
|
178 | + if (!isset($this->info['scheme'])) { |
|
179 | 179 | $this->setError( |
180 | 180 | self::ERROR_MISSING_SCHEME, |
181 | 181 | t('Cannot determine the link\'s scheme, e.g. %1$s.', 'http') |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
187 | - if(!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
187 | + if (!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
188 | 188 | $this->setError( |
189 | 189 | self::ERROR_INVALID_SCHEME, |
190 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
190 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
191 | 191 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
192 | 192 | ); |
193 | 193 | $this->isValid = false; |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | // every link needs a host. This case can happen for ex, if |
198 | 198 | // the link starts with a typo with only one slash, like: |
199 | 199 | // "http:/hostname" |
200 | - if(!isset($this->info['host'])) { |
|
200 | + if (!isset($this->info['host'])) { |
|
201 | 201 | $this->setError( |
202 | 202 | self::ERROR_MISSING_HOST, |
203 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
203 | + t('Cannot determine the link\'s host name.').' '. |
|
204 | 204 | t('This usually happens when there\'s a typo somewhere.') |
205 | 205 | ); |
206 | 206 | $this->isValid = false; |
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - if(!empty($this->info['query'])) |
|
210 | + if (!empty($this->info['query'])) |
|
211 | 211 | { |
212 | 212 | $this->params = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
213 | 213 | ksort($this->params); |
@@ -252,30 +252,30 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function filterParsed() |
254 | 254 | { |
255 | - foreach($this->info as $key => $val) |
|
255 | + foreach ($this->info as $key => $val) |
|
256 | 256 | { |
257 | - if(is_string($val)) { |
|
257 | + if (is_string($val)) { |
|
258 | 258 | $this->info[$key] = trim($val); |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | - if(isset($this->info['host'])) { |
|
262 | + if (isset($this->info['host'])) { |
|
263 | 263 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
264 | 264 | } |
265 | 265 | |
266 | - if(isset($this->info['path'])) { |
|
266 | + if (isset($this->info['path'])) { |
|
267 | 267 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | 271 | protected function detectEmail() |
272 | 272 | { |
273 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
273 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
274 | 274 | $this->isEmail = true; |
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | |
278 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
278 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
279 | 279 | { |
280 | 280 | $this->info['scheme'] = 'email'; |
281 | 281 | $this->isEmail = true; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | protected function detectFragmentLink() |
289 | 289 | { |
290 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
290 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
291 | 291 | $this->isFragment = true; |
292 | 292 | return true; |
293 | 293 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | protected function detectPhoneLink() |
299 | 299 | { |
300 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
300 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
301 | 301 | $this->isPhone = true; |
302 | 302 | return true; |
303 | 303 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function isSecure() |
313 | 313 | { |
314 | - if(isset($this->info['scheme']) && $this->info['scheme']=='https') { |
|
314 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'https') { |
|
315 | 315 | return true; |
316 | 316 | } |
317 | 317 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | public function getPort() : int |
387 | 387 | { |
388 | 388 | $port = $this->getInfoKey('port'); |
389 | - if(!empty($port)) { |
|
389 | + if (!empty($port)) { |
|
390 | 390 | return (int)$port; |
391 | 391 | } |
392 | 392 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | protected function getInfoKey(string $name) : string |
468 | 468 | { |
469 | - if(isset($this->info[$name])) { |
|
469 | + if (isset($this->info[$name])) { |
|
470 | 470 | return (string)$this->info[$name]; |
471 | 471 | } |
472 | 472 | |
@@ -475,34 +475,34 @@ discard block |
||
475 | 475 | |
476 | 476 | public function getNormalized() : string |
477 | 477 | { |
478 | - if(!$this->isValid) { |
|
478 | + if (!$this->isValid) { |
|
479 | 479 | return ''; |
480 | 480 | } |
481 | 481 | |
482 | - if($this->isFragment === true) |
|
482 | + if ($this->isFragment === true) |
|
483 | 483 | { |
484 | 484 | return '#'.$this->getFragment(); |
485 | 485 | } |
486 | - else if($this->isPhone === true) |
|
486 | + else if ($this->isPhone === true) |
|
487 | 487 | { |
488 | 488 | return 'tel://'.$this->getHost(); |
489 | 489 | } |
490 | - else if($this->isEmail === true) |
|
490 | + else if ($this->isEmail === true) |
|
491 | 491 | { |
492 | 492 | return 'mailto:'.$this->getPath(); |
493 | 493 | } |
494 | 494 | |
495 | 495 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
496 | - if(isset($this->info['path'])) { |
|
496 | + if (isset($this->info['path'])) { |
|
497 | 497 | $normalized .= $this->info['path']; |
498 | 498 | } |
499 | 499 | |
500 | 500 | $params = $this->getParams(); |
501 | - if(!empty($params)) { |
|
501 | + if (!empty($params)) { |
|
502 | 502 | $normalized .= '?'.http_build_query($params); |
503 | 503 | } |
504 | 504 | |
505 | - if(isset($this->info['fragment'])) { |
|
505 | + if (isset($this->info['fragment'])) { |
|
506 | 506 | $normalized .= '#'.$this->info['fragment']; |
507 | 507 | } |
508 | 508 | |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | */ |
531 | 531 | public function getHighlighted() : string |
532 | 532 | { |
533 | - if(!$this->isValid) { |
|
533 | + if (!$this->isValid) { |
|
534 | 534 | return ''; |
535 | 535 | } |
536 | 536 | |
537 | - if($this->isEmail) { |
|
537 | + if ($this->isEmail) { |
|
538 | 538 | return sprintf( |
539 | 539 | '<span class="link-scheme scheme-mailto">mailto:</span>'. |
540 | 540 | '<span class="link-host">%s</span>', |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | ); |
543 | 543 | } |
544 | 544 | |
545 | - if($this->isFragment) { |
|
545 | + if ($this->isFragment) { |
|
546 | 546 | return sprintf( |
547 | 547 | '<span class="link-fragment-sign">#</span>'. |
548 | 548 | '<span class="link-fragment-value">%s</span>', |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $result = ''; |
554 | 554 | |
555 | - if($this->hasScheme()) |
|
555 | + if ($this->hasScheme()) |
|
556 | 556 | { |
557 | 557 | $result = sprintf( |
558 | 558 | '<span class="link-scheme scheme-%1$s">'. |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | |
565 | 565 | $result .= '<span class="link-component double-slashes">//</span>'; |
566 | 566 | |
567 | - if($this->hasUsername()) |
|
567 | + if ($this->hasUsername()) |
|
568 | 568 | { |
569 | 569 | $result .= sprintf( |
570 | 570 | '<span class="link-credentials">%s</span>'. |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | ); |
577 | 577 | } |
578 | 578 | |
579 | - if($this->hasHost()) |
|
579 | + if ($this->hasHost()) |
|
580 | 580 | { |
581 | 581 | $result .= |
582 | 582 | sprintf( |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | ); |
586 | 586 | } |
587 | 587 | |
588 | - if($this->hasPort()) |
|
588 | + if ($this->hasPort()) |
|
589 | 589 | { |
590 | 590 | $result .= sprintf( |
591 | 591 | '<span class="link-component port-separator">:</span>'. |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | ); |
595 | 595 | } |
596 | 596 | |
597 | - if($this->hasPath()) |
|
597 | + if ($this->hasPath()) |
|
598 | 598 | { |
599 | 599 | $path = str_replace(array(';', '='), array(';<wbr>', '=<wbr>'), $this->getPath()); |
600 | 600 | $tokens = explode('/', $path); |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | ); |
606 | 606 | } |
607 | 607 | |
608 | - if(!empty($this->params)) |
|
608 | + if (!empty($this->params)) |
|
609 | 609 | { |
610 | 610 | $tokens = array(); |
611 | 611 | |
612 | - foreach($this->params as $param => $value) |
|
612 | + foreach ($this->params as $param => $value) |
|
613 | 613 | { |
614 | 614 | $parts = sprintf( |
615 | 615 | '<span class="link-param-name">%s</span>'. |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | $tag = ''; |
628 | 628 | |
629 | 629 | // is parameter exclusion enabled, and is this an excluded parameter? |
630 | - if($this->paramExclusion && isset($this->excludedParams[$param])) |
|
630 | + if ($this->paramExclusion && isset($this->excludedParams[$param])) |
|
631 | 631 | { |
632 | 632 | // display the excluded parameter, but highlight it |
633 | - if($this->highlightExcluded) |
|
633 | + if ($this->highlightExcluded) |
|
634 | 634 | { |
635 | 635 | $tooltip = $this->excludedParams[$param]; |
636 | 636 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | '<span class="link-component query-sign">?</span>'.implode('<span class="link-component param-separator">&</span>', $tokens); |
661 | 661 | } |
662 | 662 | |
663 | - if(isset($this->info['fragment'])) { |
|
663 | + if (isset($this->info['fragment'])) { |
|
664 | 664 | $result .= sprintf( |
665 | 665 | '<span class="link-fragment-sign">#</span>'. |
666 | 666 | '<span class="link-fragment">%s</span>', |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | public function getErrorMessage() : string |
685 | 685 | { |
686 | - if(isset($this->error)) { |
|
686 | + if (isset($this->error)) { |
|
687 | 687 | return $this->error['message']; |
688 | 688 | } |
689 | 689 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | public function getErrorCode() : int |
694 | 694 | { |
695 | - if(isset($this->error)) { |
|
695 | + if (isset($this->error)) { |
|
696 | 696 | return $this->error['code']; |
697 | 697 | } |
698 | 698 | |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | */ |
723 | 723 | public function getParams() : array |
724 | 724 | { |
725 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
725 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
726 | 726 | return $this->params; |
727 | 727 | } |
728 | 728 | |
729 | 729 | $keep = array(); |
730 | - foreach($this->params as $name => $value) { |
|
731 | - if(!isset($this->excludedParams[$name])) { |
|
730 | + foreach ($this->params as $name => $value) { |
|
731 | + if (!isset($this->excludedParams[$name])) { |
|
732 | 732 | $keep[$name] = $value; |
733 | 733 | } |
734 | 734 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | */ |
755 | 755 | public function getParam(string $name) : string |
756 | 756 | { |
757 | - if(isset($this->params[$name])) { |
|
757 | + if (isset($this->params[$name])) { |
|
758 | 758 | return $this->params[$name]; |
759 | 759 | } |
760 | 760 | |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function excludeParam(string $name, string $reason) : URLInfo |
775 | 775 | { |
776 | - if(!isset($this->excludedParams[$name])) |
|
776 | + if (!isset($this->excludedParams[$name])) |
|
777 | 777 | { |
778 | 778 | $this->excludedParams[$name] = $reason; |
779 | 779 | $this->setParamExclusion(); |
@@ -794,15 +794,15 @@ discard block |
||
794 | 794 | */ |
795 | 795 | public function getType() : string |
796 | 796 | { |
797 | - if($this->isEmail) { |
|
797 | + if ($this->isEmail) { |
|
798 | 798 | return self::TYPE_EMAIL; |
799 | 799 | } |
800 | 800 | |
801 | - if($this->isFragment) { |
|
801 | + if ($this->isFragment) { |
|
802 | 802 | return self::TYPE_FRAGMENT; |
803 | 803 | } |
804 | 804 | |
805 | - if($this->isPhone) { |
|
805 | + if ($this->isPhone) { |
|
806 | 806 | return self::TYPE_PHONE; |
807 | 807 | } |
808 | 808 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | |
812 | 812 | public function getTypeLabel() : string |
813 | 813 | { |
814 | - if(!isset(self::$typeLabels)) |
|
814 | + if (!isset(self::$typeLabels)) |
|
815 | 815 | { |
816 | 816 | self::$typeLabels = array( |
817 | 817 | self::TYPE_EMAIL => t('Email'), |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | $type = $this->getType(); |
825 | 825 | |
826 | - if(!isset(self::$typeLabels[$type])) |
|
826 | + if (!isset(self::$typeLabels[$type])) |
|
827 | 827 | { |
828 | 828 | throw new BaseException( |
829 | 829 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @param bool $highlight |
844 | 844 | * @return URLInfo |
845 | 845 | */ |
846 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
846 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
847 | 847 | { |
848 | 848 | $this->highlightExcluded = $highlight; |
849 | 849 | return $this; |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @see URLInfo::isParamExclusionEnabled() |
892 | 892 | * @see URLInfo::setHighlightExcluded() |
893 | 893 | */ |
894 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
894 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
895 | 895 | { |
896 | 896 | $this->paramExclusion = $enabled; |
897 | 897 | return $this; |
@@ -917,13 +917,13 @@ discard block |
||
917 | 917 | */ |
918 | 918 | public function containsExcludedParams() : bool |
919 | 919 | { |
920 | - if(empty($this->excludedParams)) { |
|
920 | + if (empty($this->excludedParams)) { |
|
921 | 921 | return false; |
922 | 922 | } |
923 | 923 | |
924 | 924 | $names = array_keys($this->params); |
925 | - foreach($names as $name) { |
|
926 | - if(isset($this->excludedParams[$name])) { |
|
925 | + foreach ($names as $name) { |
|
926 | + if (isset($this->excludedParams[$name])) { |
|
927 | 927 | return true; |
928 | 928 | } |
929 | 929 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | |
940 | 940 | public function offsetSet($offset, $value) |
941 | 941 | { |
942 | - if(in_array($offset, $this->infoKeys)) { |
|
942 | + if (in_array($offset, $this->infoKeys)) { |
|
943 | 943 | $this->info[$offset] = $value; |
944 | 944 | } |
945 | 945 | } |
@@ -956,11 +956,11 @@ discard block |
||
956 | 956 | |
957 | 957 | public function offsetGet($offset) |
958 | 958 | { |
959 | - if($offset === 'port') { |
|
959 | + if ($offset === 'port') { |
|
960 | 960 | return $this->getPort(); |
961 | 961 | } |
962 | 962 | |
963 | - if(in_array($offset, $this->infoKeys)) { |
|
963 | + if (in_array($offset, $this->infoKeys)) { |
|
964 | 964 | return $this->getInfoKey($offset); |
965 | 965 | } |
966 | 966 | |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | { |
972 | 972 | $cssFolder = realpath(__DIR__.'/../css'); |
973 | 973 | |
974 | - if($cssFolder === false) { |
|
974 | + if ($cssFolder === false) { |
|
975 | 975 | throw new BaseException( |
976 | 976 | 'Cannot find package CSS folder.', |
977 | 977 | null, |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | return $this->setOption('separatorChar', $char); |
18 | 18 | } |
19 | 19 | |
20 | - public function setTrailingNewline($useNewline=true) |
|
20 | + public function setTrailingNewline($useNewline = true) |
|
21 | 21 | { |
22 | 22 | return $this->setOption('trailingNewline', $useNewline); |
23 | 23 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $args = $args[0]; |
39 | 39 | } |
40 | 40 | |
41 | - $this->lines[] = '"' . implode('"'.$this->getOption('separatorChar').'"', $args) . '"'; |
|
41 | + $this->lines[] = '"'.implode('"'.$this->getOption('separatorChar').'"', $args).'"'; |
|
42 | 42 | |
43 | 43 | return $this; |
44 | 44 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $csv = implode(PHP_EOL, $this->lines); |
56 | 56 | |
57 | - if($this->getOption('trailingNewline')) { |
|
57 | + if ($this->getOption('trailingNewline')) { |
|
58 | 58 | $csv .= PHP_EOL; |
59 | 59 | } |
60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setOption($name, $value) |
67 | 67 | { |
68 | - if(!isset($this->options)) { |
|
68 | + if (!isset($this->options)) { |
|
69 | 69 | $this->options = $this->getDefaultOptions(); |
70 | 70 | } |
71 | 71 | |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | |
76 | 76 | public function setOptions($options) |
77 | 77 | { |
78 | - foreach($options as $name => $value) { |
|
78 | + foreach ($options as $name => $value) { |
|
79 | 79 | $this->setOption($name, $value); |
80 | 80 | } |
81 | 81 | |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function getOption($name, $default=null) |
|
85 | + public function getOption($name, $default = null) |
|
86 | 86 | { |
87 | - if(!isset($this->options)) { |
|
87 | + if (!isset($this->options)) { |
|
88 | 88 | $this->options = $this->getDefaultOptions(); |
89 | 89 | } |
90 | 90 | |
91 | - if(isset($this->options[$name])) { |
|
91 | + if (isset($this->options[$name])) { |
|
92 | 92 | return $this->options[$name]; |
93 | 93 | } |
94 | 94 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public function hasOption($name) |
99 | 99 | { |
100 | - if(!isset($this->options)) { |
|
100 | + if (!isset($this->options)) { |
|
101 | 101 | $this->options = $this->getDefaultOptions(); |
102 | 102 | } |
103 | 103 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | public function getOptions() |
108 | 108 | { |
109 | - if(!isset($this->options)) { |
|
109 | + if (!isset($this->options)) { |
|
110 | 110 | $this->options = $this->getDefaultOptions(); |
111 | 111 | } |
112 | 112 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | public function isOption($name, $value) |
117 | 117 | { |
118 | - if($this->getOption($name) === $value) { |
|
118 | + if ($this->getOption($name) === $value) { |
|
119 | 119 | return true; |
120 | 120 | } |
121 | 121 |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | |
37 | 37 | protected $classes = array(); |
38 | 38 | |
39 | - /** |
|
40 | - * The namespace detected in the file, if any. |
|
41 | - * @var string |
|
42 | - */ |
|
39 | + /** |
|
40 | + * The namespace detected in the file, if any. |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $namespace = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @param string $path The path to the PHP file to parse. |
|
47 | - * @throws FileHelper_Exception |
|
48 | - * @see FileHelper::findPHPClasses() |
|
49 | - */ |
|
45 | + /** |
|
46 | + * @param string $path The path to the PHP file to parse. |
|
47 | + * @throws FileHelper_Exception |
|
48 | + * @see FileHelper::findPHPClasses() |
|
49 | + */ |
|
50 | 50 | public function __construct(string $path) |
51 | 51 | { |
52 | 52 | $this->path = realpath($path); |
@@ -66,66 +66,66 @@ discard block |
||
66 | 66 | $this->parseFile(); |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * The name of the namespace of the classes in the file, if any. |
|
71 | - * @return string |
|
72 | - */ |
|
69 | + /** |
|
70 | + * The name of the namespace of the classes in the file, if any. |
|
71 | + * @return string |
|
72 | + */ |
|
73 | 73 | public function getNamespace() : string |
74 | 74 | { |
75 | 75 | return $this->namespace; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Whether the file contains a namespace. |
|
80 | - * @return bool |
|
81 | - */ |
|
78 | + /** |
|
79 | + * Whether the file contains a namespace. |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | 82 | public function hasNamespace() : bool |
83 | 83 | { |
84 | 84 | return !empty($this->namespace); |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * The absolute path to the file. |
|
89 | - * @return string |
|
90 | - */ |
|
87 | + /** |
|
88 | + * The absolute path to the file. |
|
89 | + * @return string |
|
90 | + */ |
|
91 | 91 | public function getPath() : string |
92 | 92 | { |
93 | 93 | return $this->path; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether any classes were found in the file. |
|
98 | - * @return bool |
|
99 | - */ |
|
96 | + /** |
|
97 | + * Whether any classes were found in the file. |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function hasClasses() : bool |
101 | 101 | { |
102 | 102 | return !empty($this->classes); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * The names of the classes that were found in the file (with namespace if any). |
|
107 | - * @return string[] |
|
108 | - */ |
|
105 | + /** |
|
106 | + * The names of the classes that were found in the file (with namespace if any). |
|
107 | + * @return string[] |
|
108 | + */ |
|
109 | 109 | public function getClassNames() : array |
110 | 110 | { |
111 | 111 | return array_keys($this->classes); |
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Retrieves all classes that were detected in the file, |
|
116 | - * which can be used to retrieve more information about |
|
117 | - * them. |
|
118 | - * |
|
119 | - * @return FileHelper_PHPClassInfo_Class[] |
|
120 | - */ |
|
114 | + /** |
|
115 | + * Retrieves all classes that were detected in the file, |
|
116 | + * which can be used to retrieve more information about |
|
117 | + * them. |
|
118 | + * |
|
119 | + * @return FileHelper_PHPClassInfo_Class[] |
|
120 | + */ |
|
121 | 121 | public function getClasses() |
122 | 122 | { |
123 | 123 | return $this->classes; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * @throws FileHelper_Exception |
|
128 | - */ |
|
126 | + /** |
|
127 | + * @throws FileHelper_Exception |
|
128 | + */ |
|
129 | 129 | protected function parseFile() |
130 | 130 | { |
131 | 131 | $code = file_get_contents($this->path); |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - /** |
|
184 | - * Strips all whitespace from the string, replacing it with |
|
185 | - * regular spaces (newlines, tabs, etc.). |
|
186 | - * |
|
187 | - * @param string $string |
|
188 | - * @return string |
|
189 | - */ |
|
183 | + /** |
|
184 | + * Strips all whitespace from the string, replacing it with |
|
185 | + * regular spaces (newlines, tabs, etc.). |
|
186 | + * |
|
187 | + * @param string $string |
|
188 | + * @return string |
|
189 | + */ |
|
190 | 190 | protected function stripWhitespace(string $string) : string |
191 | 191 | { |
192 | 192 | return preg_replace('/[\s]/', ' ', $string); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $this->path = realpath($path); |
53 | 53 | |
54 | - if($this->path === false) |
|
54 | + if ($this->path === false) |
|
55 | 55 | { |
56 | 56 | throw new FileHelper_Exception( |
57 | 57 | 'Cannot extract file information: file not found.', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | { |
131 | 131 | $code = file_get_contents($this->path); |
132 | 132 | |
133 | - if($code === false) |
|
133 | + if ($code === false) |
|
134 | 134 | { |
135 | 135 | throw new FileHelper_Exception( |
136 | 136 | 'Cannot open file for parsing.', |
@@ -149,24 +149,24 @@ discard block |
||
149 | 149 | |
150 | 150 | $result = array(); |
151 | 151 | preg_match_all('/namespace[\s]+([^;]+);/six', $code, $result, PREG_PATTERN_ORDER); |
152 | - if(isset($result[0]) && isset($result[0][0])) { |
|
152 | + if (isset($result[0]) && isset($result[0][0])) { |
|
153 | 153 | $this->namespace = trim($result[1][0]); |
154 | 154 | } |
155 | 155 | |
156 | 156 | $result = array(); |
157 | 157 | preg_match_all('/(abstract|final)[\s]+class[\s]+([\sa-z0-9\\\\_,]+){|class[\s]+([\sa-z0-9\\\\_,]+){/six', $code, $result, PREG_PATTERN_ORDER); |
158 | 158 | |
159 | - if(!isset($result[0]) || !isset($result[0][0])) { |
|
159 | + if (!isset($result[0]) || !isset($result[0][0])) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | $indexes = array_keys($result[0]); |
164 | 164 | |
165 | - foreach($indexes as $idx) |
|
165 | + foreach ($indexes as $idx) |
|
166 | 166 | { |
167 | 167 | $keyword = $result[1][$idx]; |
168 | 168 | $declaration = $result[2][$idx]; |
169 | - if(empty($keyword)) { |
|
169 | + if (empty($keyword)) { |
|
170 | 170 | $declaration = $result[3][$idx]; |
171 | 171 | } |
172 | 172 |
@@ -147,8 +147,7 @@ discard block |
||
147 | 147 | if($this->getOption('recursive') === true && !$item->isDot()) { |
148 | 148 | $this->find($item->getPathname()); |
149 | 149 | } |
150 | - } |
|
151 | - else |
|
150 | + } else |
|
152 | 151 | { |
153 | 152 | $file = $this->filterFile($item->getPathname()); |
154 | 153 | if($file) { |
@@ -172,8 +171,7 @@ discard block |
||
172 | 171 | if(!in_array($info['extension'], $include)) { |
173 | 172 | return false; |
174 | 173 | } |
175 | - } |
|
176 | - else if(!empty($exclude)) |
|
174 | + } else if(!empty($exclude)) |
|
177 | 175 | { |
178 | 176 | if(in_array($info['extension'], $exclude)) { |
179 | 177 | return false; |
@@ -31,9 +31,9 @@ |
||
31 | 31 | |
32 | 32 | const PATH_MODE_STRIP = 'strip'; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | protected $path; |
38 | 38 | |
39 | 39 | public function __construct(string $path) |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see FileHelper_FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils; |
13 | 13 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | public function getAll() : array |
127 | 127 | { |
128 | - if(!isset($this->found)) { |
|
128 | + if (!isset($this->found)) { |
|
129 | 129 | $this->find($this->path, true); |
130 | 130 | } |
131 | 131 | |
@@ -150,25 +150,25 @@ discard block |
||
150 | 150 | |
151 | 151 | protected $found; |
152 | 152 | |
153 | - protected function find($path, $isRoot=false) |
|
153 | + protected function find($path, $isRoot = false) |
|
154 | 154 | { |
155 | - if($isRoot) { |
|
155 | + if ($isRoot) { |
|
156 | 156 | $this->found = array(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $d = new \DirectoryIterator($path); |
160 | - foreach($d as $item) |
|
160 | + foreach ($d as $item) |
|
161 | 161 | { |
162 | - if($item->isDir()) |
|
162 | + if ($item->isDir()) |
|
163 | 163 | { |
164 | - if($this->getOption('recursive') === true && !$item->isDot()) { |
|
164 | + if ($this->getOption('recursive') === true && !$item->isDot()) { |
|
165 | 165 | $this->find($item->getPathname()); |
166 | 166 | } |
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | 170 | $file = $this->filterFile($item->getPathname()); |
171 | - if($file) { |
|
171 | + if ($file) { |
|
172 | 172 | $this->found[] = $file; |
173 | 173 | } |
174 | 174 | } |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | $include = $this->getOption('include-extensions'); |
185 | 185 | $exclude = $this->getOption('exclude-extensions'); |
186 | 186 | |
187 | - if(!empty($include)) |
|
187 | + if (!empty($include)) |
|
188 | 188 | { |
189 | - if(!in_array($info['extension'], $include)) { |
|
189 | + if (!in_array($info['extension'], $include)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | } |
193 | - else if(!empty($exclude)) |
|
193 | + else if (!empty($exclude)) |
|
194 | 194 | { |
195 | - if(in_array($info['extension'], $exclude)) { |
|
195 | + if (in_array($info['extension'], $exclude)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - switch($this->getOption('pathmode')) |
|
200 | + switch ($this->getOption('pathmode')) |
|
201 | 201 | { |
202 | 202 | case self::PATH_MODE_STRIP: |
203 | 203 | $path = basename($path); |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | break; |
214 | 214 | } |
215 | 215 | |
216 | - if($this->getOption('strip-extensions') === true) |
|
216 | + if ($this->getOption('strip-extensions') === true) |
|
217 | 217 | { |
218 | 218 | $path = str_replace('.'.$info['extension'], '', $path); |
219 | 219 | } |
220 | 220 | |
221 | 221 | $replace = $this->getOption('slash-replacement'); |
222 | - if(!empty($replace)) { |
|
222 | + if (!empty($replace)) { |
|
223 | 223 | $path = str_replace('/', $replace, $path); |
224 | 224 | } |
225 | 225 |
@@ -221,7 +221,7 @@ |
||
221 | 221 | */ |
222 | 222 | public static function getMime($extension) |
223 | 223 | { |
224 | - if(isset(self::$mimeTypes[$extension])) { |
|
224 | + if (isset(self::$mimeTypes[$extension])) { |
|
225 | 225 | return self::$mimeTypes[$extension]; |
226 | 226 | } |
227 | 227 |
@@ -22,51 +22,51 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class FileHelper_PHPClassInfo_Class |
24 | 24 | { |
25 | - /** |
|
26 | - * @var FileHelper_PHPClassInfo |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var FileHelper_PHPClassInfo |
|
27 | + */ |
|
28 | 28 | protected $info; |
29 | 29 | |
30 | - /** |
|
31 | - * @var bool |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var bool |
|
32 | + */ |
|
33 | 33 | protected $abstract = false; |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | 38 | protected $final = false; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $extends = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[] |
|
47 | + */ |
|
48 | 48 | protected $implements = array(); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $name; |
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | 58 | protected $declaration; |
59 | 59 | |
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | 63 | protected $keyword; |
64 | 64 | |
65 | - /** |
|
66 | - * @param FileHelper_PHPClassInfo $info The class info instance. |
|
67 | - * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
68 | - * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
69 | - */ |
|
65 | + /** |
|
66 | + * @param FileHelper_PHPClassInfo $info The class info instance. |
|
67 | + * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
68 | + * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
69 | + */ |
|
70 | 70 | public function __construct(FileHelper_PHPClassInfo $info, string $declaration, string $keyword) |
71 | 71 | { |
72 | 72 | $this->info = $info; |
@@ -76,31 +76,31 @@ discard block |
||
76 | 76 | $this->analyzeCode(); |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Check if this class is a subclass of the specified |
|
81 | - * class name. |
|
82 | - * |
|
83 | - * @param string $className |
|
84 | - * @return bool |
|
85 | - */ |
|
79 | + /** |
|
80 | + * Check if this class is a subclass of the specified |
|
81 | + * class name. |
|
82 | + * |
|
83 | + * @param string $className |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | 86 | public function isSublassOf(string $className) : bool |
87 | 87 | { |
88 | 88 | return is_subclass_of($this->getNameNS(), $className); |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * The class name without namespace. |
|
93 | - * @return string |
|
94 | - */ |
|
91 | + /** |
|
92 | + * The class name without namespace. |
|
93 | + * @return string |
|
94 | + */ |
|
95 | 95 | public function getName() : string |
96 | 96 | { |
97 | 97 | return $this->name; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * The absolute class name with namespace (if any). |
|
102 | - * @return string |
|
103 | - */ |
|
100 | + /** |
|
101 | + * The absolute class name with namespace (if any). |
|
102 | + * @return string |
|
103 | + */ |
|
104 | 104 | public function getNameNS() : string |
105 | 105 | { |
106 | 106 | $name = $this->getName(); |
@@ -112,48 +112,48 @@ discard block |
||
112 | 112 | return $name; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Whether it is an abstract class. |
|
117 | - * @return bool |
|
118 | - */ |
|
115 | + /** |
|
116 | + * Whether it is an abstract class. |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | 119 | public function isAbstract() : bool |
120 | 120 | { |
121 | 121 | return $this->abstract; |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Whether it is a final class. |
|
126 | - * @return bool |
|
127 | - */ |
|
124 | + /** |
|
125 | + * Whether it is a final class. |
|
126 | + * @return bool |
|
127 | + */ |
|
128 | 128 | public function isFinal() : bool |
129 | 129 | { |
130 | 130 | return $this->final; |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * The name of the class that this class extends (with namespace, if specified). |
|
135 | - * @return string |
|
136 | - */ |
|
133 | + /** |
|
134 | + * The name of the class that this class extends (with namespace, if specified). |
|
135 | + * @return string |
|
136 | + */ |
|
137 | 137 | public function getExtends() : string |
138 | 138 | { |
139 | 139 | return $this->extends; |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * A list of interfaces the class implements, if any. |
|
144 | - * @return array |
|
145 | - */ |
|
142 | + /** |
|
143 | + * A list of interfaces the class implements, if any. |
|
144 | + * @return array |
|
145 | + */ |
|
146 | 146 | public function getImplements() : array |
147 | 147 | { |
148 | 148 | return $this->implements; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * The class declaration string, with normalized spaces and sorted interface names. |
|
153 | - * NOTE: does not include the keyword "abstract" or "final". |
|
154 | - * |
|
155 | - * @return string |
|
156 | - */ |
|
151 | + /** |
|
152 | + * The class declaration string, with normalized spaces and sorted interface names. |
|
153 | + * NOTE: does not include the keyword "abstract" or "final". |
|
154 | + * |
|
155 | + * @return string |
|
156 | + */ |
|
157 | 157 | public function getDeclaration() : string |
158 | 158 | { |
159 | 159 | $parts = array(); |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | return implode(' ', $parts); |
174 | 174 | } |
175 | 175 | |
176 | - /** |
|
177 | - * The keyword before "class", e.g. "abstract". |
|
178 | - * @return string |
|
179 | - */ |
|
176 | + /** |
|
177 | + * The keyword before "class", e.g. "abstract". |
|
178 | + * @return string |
|
179 | + */ |
|
180 | 180 | public function getKeyword() : string |
181 | 181 | { |
182 | 182 | return $this->keyword; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $name = $this->getName(); |
107 | 107 | |
108 | - if($this->info->hasNamespace()) { |
|
108 | + if ($this->info->hasNamespace()) { |
|
109 | 109 | $name = $this->info->getNamespace().'\\'.$this->name; |
110 | 110 | } |
111 | 111 | |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | $parts[] = 'class'; |
161 | 161 | $parts[] = $this->getName(); |
162 | 162 | |
163 | - if(!empty($this->extends)) { |
|
163 | + if (!empty($this->extends)) { |
|
164 | 164 | $parts[] = 'extends'; |
165 | 165 | $parts[] = $this->extends; |
166 | 166 | } |
167 | 167 | |
168 | - if(!empty($this->implements)) { |
|
168 | + if (!empty($this->implements)) { |
|
169 | 169 | $parts[] = 'implements'; |
170 | 170 | $parts[] = implode(', ', $this->implements); |
171 | 171 | } |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | |
185 | 185 | protected function analyzeCode() |
186 | 186 | { |
187 | - if($this->keyword == 'abstract') { |
|
187 | + if ($this->keyword == 'abstract') { |
|
188 | 188 | $this->abstract = true; |
189 | - } else if($this->keyword == 'final') { |
|
189 | + } else if ($this->keyword == 'final') { |
|
190 | 190 | $this->final = true; |
191 | 191 | } |
192 | 192 | |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | |
204 | 204 | $tokenName = 'none'; |
205 | 205 | |
206 | - foreach($parts as $part) |
|
206 | + foreach ($parts as $part) |
|
207 | 207 | { |
208 | 208 | $part = str_replace(',', '', $part); |
209 | 209 | $part = trim($part); |
210 | - if(empty($part)) { |
|
210 | + if (empty($part)) { |
|
211 | 211 | continue; |
212 | 212 | } |
213 | 213 | |
214 | 214 | $name = strtolower($part); |
215 | - if($name == 'extends' || $name == 'implements') { |
|
215 | + if ($name == 'extends' || $name == 'implements') { |
|
216 | 216 | $tokenName = $name; |
217 | 217 | continue; |
218 | 218 | } |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | |
223 | 223 | $this->implements = $tokens['implements']; |
224 | 224 | |
225 | - if(!empty($this->implements)) { |
|
225 | + if (!empty($this->implements)) { |
|
226 | 226 | usort($this->implements, function(string $a, string $b) { |
227 | 227 | return strnatcasecmp($a, $b); |
228 | 228 | }); |
229 | 229 | } |
230 | 230 | |
231 | - if(!empty($tokens['extends'])) { |
|
231 | + if (!empty($tokens['extends'])) { |
|
232 | 232 | $this->extends = $tokens['extends'][0]; |
233 | 233 | } |
234 | 234 | } |
@@ -18,23 +18,23 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __construct(array $size) |
20 | 20 | { |
21 | - if(!isset($size['width'])) { |
|
21 | + if (!isset($size['width'])) { |
|
22 | 22 | $size['width'] = $size[0]; |
23 | 23 | } |
24 | 24 | |
25 | - if(!isset($size['height'])) { |
|
25 | + if (!isset($size['height'])) { |
|
26 | 26 | $size['height'] = $size[1]; |
27 | 27 | } |
28 | 28 | |
29 | - if(!isset($size[0])) { |
|
29 | + if (!isset($size[0])) { |
|
30 | 30 | $size[0] = $size['width']; |
31 | 31 | } |
32 | 32 | |
33 | - if(!isset($size[1])) { |
|
33 | + if (!isset($size[1])) { |
|
34 | 34 | $size[1] = $size['height']; |
35 | 35 | } |
36 | 36 | |
37 | - if(!isset($size['channels'])) { |
|
37 | + if (!isset($size['channels'])) { |
|
38 | 38 | $size['channels'] = 1; |
39 | 39 | } |
40 | 40 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function offsetGet($offset) |
70 | 70 | { |
71 | - if(isset($this->size[$offset])) { |
|
71 | + if (isset($this->size[$offset])) { |
|
72 | 72 | return $this->size[$offset]; |
73 | 73 | } |
74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function offsetSet($offset, $value) |
79 | 79 | { |
80 | - if(is_null($offset)) { |
|
80 | + if (is_null($offset)) { |
|
81 | 81 | $this->size[] = $value; |
82 | 82 | } else { |
83 | 83 | $this->size[$offset] = $value; |