@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | { |
7 | 7 | protected $details; |
8 | 8 | |
9 | - public function __construct($message, $details=null, $code=null, $previous=null) |
|
9 | + public function __construct($message, $details = null, $code = null, $previous = null) |
|
10 | 10 | { |
11 | 11 | parent::__construct($message, $code, $previous); |
12 | 12 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function getDetails() : string |
21 | 21 | { |
22 | - if($this->details !== null) { |
|
22 | + if ($this->details !== null) { |
|
23 | 23 | return $this->details; |
24 | 24 | } |
25 | 25 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function display() |
34 | 34 | { |
35 | - if(!headers_sent()) { |
|
35 | + if (!headers_sent()) { |
|
36 | 36 | header('Content-type:text/plain; charset=utf-8'); |
37 | 37 | } |
38 | 38 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | throw new BaseException(''); |
62 | 62 | } |
63 | - catch(BaseException $e) |
|
63 | + catch (BaseException $e) |
|
64 | 64 | { |
65 | 65 | echo self::createInfo($e)->toString(); |
66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | throw new BaseException(''); |
77 | 77 | } |
78 | - catch(BaseException $e) |
|
78 | + catch (BaseException $e) |
|
79 | 79 | { |
80 | 80 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
81 | 81 | echo self::createInfo($e)->toString(); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function loadFile($file) |
109 | 109 | { |
110 | 110 | $csv = file_get_contents($file); |
111 | - if(!$csv) { |
|
111 | + if (!$csv) { |
|
112 | 112 | throw new CSVHelper_Exception( |
113 | 113 | 'Cannot read csv file', |
114 | 114 | sprintf( |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | public function isHeadersPosition($position) |
174 | 174 | { |
175 | - if($this->headersPosition === $position) { |
|
175 | + if ($this->headersPosition === $position) { |
|
176 | 176 | return true; |
177 | 177 | } |
178 | 178 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | self::HEADERS_TOP |
200 | 200 | ); |
201 | 201 | |
202 | - if(!in_array($position, $validPositions)) { |
|
202 | + if (!in_array($position, $validPositions)) { |
|
203 | 203 | throw new CSVHelper_Exception( |
204 | 204 | 'Invalid headers position', |
205 | 205 | sprintf( |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function getRow($index) |
257 | 257 | { |
258 | - if(isset($this->data[$index])) { |
|
258 | + if (isset($this->data[$index])) { |
|
259 | 259 | return $this->data[$index]; |
260 | 260 | } |
261 | 261 | |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | public function getColumn($index) |
323 | 323 | { |
324 | 324 | $data = array(); |
325 | - for($i=0; $i < $this->rowCount; $i++) { |
|
325 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
326 | 326 | $value = ''; |
327 | - if(isset($this->data[$i][$index])) { |
|
327 | + if (isset($this->data[$i][$index])) { |
|
328 | 328 | $value = $this->data[$i][$index]; |
329 | 329 | } |
330 | 330 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function columnExists($index) |
343 | 343 | { |
344 | - if($index < $this->columnCount) { |
|
344 | + if ($index < $this->columnCount) { |
|
345 | 345 | return true; |
346 | 346 | } |
347 | 347 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | { |
353 | 353 | $this->reset(); |
354 | 354 | |
355 | - if(empty(trim($this->csv))) { |
|
355 | + if (empty(trim($this->csv))) { |
|
356 | 356 | $this->addError('Tried to parse an empty CSV string.'); |
357 | 357 | return; |
358 | 358 | } |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | $parser->delimiter = $this->detectSeparator(); |
368 | 368 | |
369 | 369 | $result = $parser->parse_string($this->csv); |
370 | - if(!$result) { |
|
370 | + if (!$result) { |
|
371 | 371 | $this->addError('The CSV string could not be parsed.'); |
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | - switch($this->headersPosition) |
|
375 | + switch ($this->headersPosition) |
|
376 | 376 | { |
377 | 377 | case self::HEADERS_TOP: |
378 | 378 | $this->headers = array_shift($result); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | case self::HEADERS_LEFT: |
382 | 382 | $keep = array(); |
383 | 383 | $total = count($result); |
384 | - for($i=0; $i < $total; $i++) { |
|
384 | + for ($i = 0; $i < $total; $i++) { |
|
385 | 385 | $row = $result[$i]; |
386 | 386 | $this->headers[] = array_shift($row); |
387 | 387 | $keep[] = $row; |
@@ -394,9 +394,9 @@ discard block |
||
394 | 394 | $this->data = $result; |
395 | 395 | $this->rowCount = count($this->data); |
396 | 396 | |
397 | - for($i=0; $i < $this->rowCount; $i++) { |
|
397 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
398 | 398 | $amount = count($this->data[$i]); |
399 | - if($amount > $this->columnCount) { |
|
399 | + if ($amount > $this->columnCount) { |
|
400 | 400 | $this->columnCount = $amount; |
401 | 401 | } |
402 | 402 | } |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | ',,' => ',' |
441 | 441 | ); |
442 | 442 | |
443 | - foreach($search as $char => $separator) { |
|
444 | - if(strstr($this->csv, $char)) { |
|
443 | + foreach ($search as $char => $separator) { |
|
444 | + if (strstr($this->csv, $char)) { |
|
445 | 445 | return $separator; |
446 | 446 | } |
447 | 447 | } |
@@ -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: |
@@ -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 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | const ERROR_OPENING_ZIP_FILE = 338003; |
32 | 32 | |
33 | - const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
33 | + const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
34 | 34 | |
35 | 35 | protected $options = array( |
36 | 36 | 'WriteThreshold' => 100 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @throws ZIPHelper_Exception |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public function addFile($filePath, $zipPath=null) |
|
78 | + public function addFile($filePath, $zipPath = null) |
|
79 | 79 | { |
80 | 80 | $this->open(); |
81 | 81 | |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | |
121 | 121 | protected function open() |
122 | 122 | { |
123 | - if($this->open) { |
|
123 | + if ($this->open) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | - if(!isset($this->zip)) { |
|
127 | + if (!isset($this->zip)) { |
|
128 | 128 | $this->zip = new \ZipArchive(); |
129 | 129 | } |
130 | 130 | |
131 | 131 | $flag = null; |
132 | - if(!file_exists($this->file)) { |
|
132 | + if (!file_exists($this->file)) { |
|
133 | 133 | $flag = \ZipArchive::CREATE; |
134 | 134 | } |
135 | 135 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | $this->fileTracker++; |
171 | 171 | |
172 | - if($this->options['WriteThreshold'] < 1) { |
|
172 | + if ($this->options['WriteThreshold'] < 1) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | protected function close() |
184 | 184 | { |
185 | - if(!$this->open) { |
|
185 | + if (!$this->open) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | throw new ZIPHelper_Exception( |
191 | 191 | 'Could not save ZIP file to disk', |
192 | 192 | sprintf( |
193 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
194 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
193 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
194 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
195 | 195 | 'or trying to save to a directory that does not exist.', |
196 | 196 | $this->file |
197 | 197 | ), |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | * @see ZIPHelper::downloadAndDelete() |
229 | 229 | * @throws ZIPHelper_Exception |
230 | 230 | */ |
231 | - public function download($fileName=null) |
|
231 | + public function download($fileName = null) |
|
232 | 232 | { |
233 | 233 | $this->save(); |
234 | 234 | |
235 | - if(empty($fileName)) { |
|
235 | + if (empty($fileName)) { |
|
236 | 236 | $fileName = basename($this->file); |
237 | 237 | } |
238 | 238 | |
239 | 239 | header('Content-type: application/zip'); |
240 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
241 | - header('Content-length: ' . filesize($this->file)); |
|
240 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
241 | + header('Content-length: '.filesize($this->file)); |
|
242 | 242 | header('Pragma: no-cache'); |
243 | 243 | header('Expires: 0'); |
244 | 244 | readfile($this->file); |
245 | 245 | |
246 | - if($this->exit === false) { |
|
246 | + if ($this->exit === false) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string|NULL $fileName Override the ZIP's file name for the download |
260 | 260 | * @see ZIPHelper::download() |
261 | 261 | */ |
262 | - public function downloadAndDelete($fileName=null) |
|
262 | + public function downloadAndDelete($fileName = null) |
|
263 | 263 | { |
264 | 264 | $this->exit = false; |
265 | 265 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @param string $outputFolder |
281 | 281 | * @return boolean |
282 | 282 | */ |
283 | - public function extractAll($outputFolder=null) |
|
283 | + public function extractAll($outputFolder = null) |
|
284 | 284 | { |
285 | - if(empty($outputFolder)) { |
|
285 | + if (empty($outputFolder)) { |
|
286 | 286 | $outputFolder = dirname($this->file); |
287 | 287 | } |
288 | 288 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * The converted string will be all lowercase. |
61 | 61 | * @return Transliteration |
62 | 62 | */ |
63 | - public function setLowercase(bool $lowercase=true) : Transliteration |
|
63 | + public function setLowercase(bool $lowercase = true) : Transliteration |
|
64 | 64 | { |
65 | 65 | $this->setOption('lowercase', true); |
66 | 66 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | |
98 | 98 | $result = implode('', $keep); |
99 | 99 | |
100 | - while (strstr($result, $space . $space)) { |
|
101 | - $result = str_replace($space . $space, $space, $result); |
|
100 | + while (strstr($result, $space.$space)) { |
|
101 | + $result = str_replace($space.$space, $space, $result); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $result = trim($result, $space); |
@@ -117,26 +117,26 @@ discard block |
||
117 | 117 | |
118 | 118 | $this->filterParsed(); |
119 | 119 | |
120 | - if($this->detectEmail()) { |
|
120 | + if ($this->detectEmail()) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | - if($this->detectFragmentLink()) { |
|
124 | + if ($this->detectFragmentLink()) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - if($this->detectPhoneLink()) { |
|
128 | + if ($this->detectPhoneLink()) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | 131 | |
132 | - if(!$this->isValid) { |
|
132 | + if (!$this->isValid) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // no scheme found: it may be an email address without the mailto: |
137 | 137 | // It can't be a variable, since without the scheme it would already |
138 | 138 | // have been recognized as a vaiable only link. |
139 | - if(!isset($this->info['scheme'])) { |
|
139 | + if (!isset($this->info['scheme'])) { |
|
140 | 140 | $this->setError( |
141 | 141 | self::ERROR_MISSING_SCHEME, |
142 | 142 | t('Cannot determine the link\'s scheme, e.g. %1$s.', 'http') |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - if(!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
148 | + if (!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
149 | 149 | $this->setError( |
150 | 150 | self::ERROR_INVALID_SCHEME, |
151 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
151 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
152 | 152 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
153 | 153 | ); |
154 | 154 | $this->isValid = false; |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | // every link needs a host. This case can happen for ex, if |
159 | 159 | // the link starts with a typo with only one slash, like: |
160 | 160 | // "http:/hostname" |
161 | - if(!isset($this->info['host'])) { |
|
161 | + if (!isset($this->info['host'])) { |
|
162 | 162 | $this->setError( |
163 | 163 | self::ERROR_MISSING_HOST, |
164 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
164 | + t('Cannot determine the link\'s host name.').' '. |
|
165 | 165 | t('This usually happens when there\'s a typo somewhere.') |
166 | 166 | ); |
167 | 167 | $this->isValid = false; |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if(!empty($this->info['query'])) |
|
171 | + if (!empty($this->info['query'])) |
|
172 | 172 | { |
173 | 173 | $this->params = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
174 | 174 | ksort($this->params); |
@@ -213,30 +213,30 @@ discard block |
||
213 | 213 | */ |
214 | 214 | protected function filterParsed() |
215 | 215 | { |
216 | - foreach($this->info as $key => $val) |
|
216 | + foreach ($this->info as $key => $val) |
|
217 | 217 | { |
218 | - if(is_string($val)) { |
|
218 | + if (is_string($val)) { |
|
219 | 219 | $this->info[$key] = trim($val); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if(isset($this->info['host'])) { |
|
223 | + if (isset($this->info['host'])) { |
|
224 | 224 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
225 | 225 | } |
226 | 226 | |
227 | - if(isset($this->info['path'])) { |
|
227 | + if (isset($this->info['path'])) { |
|
228 | 228 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | protected function detectEmail() |
233 | 233 | { |
234 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
234 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
235 | 235 | $this->isEmail = true; |
236 | 236 | return true; |
237 | 237 | } |
238 | 238 | |
239 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
239 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
240 | 240 | { |
241 | 241 | $this->info['scheme'] = 'email'; |
242 | 242 | $this->isEmail = true; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | protected function detectFragmentLink() |
250 | 250 | { |
251 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
251 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
252 | 252 | $this->isFragment = true; |
253 | 253 | return true; |
254 | 254 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | protected function detectPhoneLink() |
260 | 260 | { |
261 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
261 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
262 | 262 | $this->isPhone = true; |
263 | 263 | return true; |
264 | 264 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function isSecure() |
274 | 274 | { |
275 | - if(isset($this->info['scheme']) && $this->info['scheme']=='https') { |
|
275 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'https') { |
|
276 | 276 | return true; |
277 | 277 | } |
278 | 278 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | public function getPort() : int |
348 | 348 | { |
349 | 349 | $port = $this->getInfoKey('port'); |
350 | - if(!empty($port)) { |
|
350 | + if (!empty($port)) { |
|
351 | 351 | return (int)$port; |
352 | 352 | } |
353 | 353 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | |
428 | 428 | protected function getInfoKey(string $name) : string |
429 | 429 | { |
430 | - if(isset($this->info[$name])) { |
|
430 | + if (isset($this->info[$name])) { |
|
431 | 431 | return (string)$this->info[$name]; |
432 | 432 | } |
433 | 433 | |
@@ -436,34 +436,34 @@ discard block |
||
436 | 436 | |
437 | 437 | public function getNormalized() : string |
438 | 438 | { |
439 | - if(!$this->isValid) { |
|
439 | + if (!$this->isValid) { |
|
440 | 440 | return ''; |
441 | 441 | } |
442 | 442 | |
443 | - if($this->isFragment === true) |
|
443 | + if ($this->isFragment === true) |
|
444 | 444 | { |
445 | 445 | return '#'.$this->getFragment(); |
446 | 446 | } |
447 | - else if($this->isPhone === true) |
|
447 | + else if ($this->isPhone === true) |
|
448 | 448 | { |
449 | 449 | return 'tel://'.$this->getHost(); |
450 | 450 | } |
451 | - else if($this->isEmail === true) |
|
451 | + else if ($this->isEmail === true) |
|
452 | 452 | { |
453 | 453 | return 'mailto:'.$this->getPath(); |
454 | 454 | } |
455 | 455 | |
456 | 456 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
457 | - if(isset($this->info['path'])) { |
|
457 | + if (isset($this->info['path'])) { |
|
458 | 458 | $normalized .= $this->info['path']; |
459 | 459 | } |
460 | 460 | |
461 | 461 | $params = $this->getParams(); |
462 | - if(!empty($params)) { |
|
462 | + if (!empty($params)) { |
|
463 | 463 | $normalized .= '?'.http_build_query($params); |
464 | 464 | } |
465 | 465 | |
466 | - if(isset($this->info['fragment'])) { |
|
466 | + if (isset($this->info['fragment'])) { |
|
467 | 467 | $normalized .= '#'.$this->info['fragment']; |
468 | 468 | } |
469 | 469 | |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public function getHighlighted() : string |
493 | 493 | { |
494 | - if(!$this->isValid) { |
|
494 | + if (!$this->isValid) { |
|
495 | 495 | return ''; |
496 | 496 | } |
497 | 497 | |
498 | - if($this->isEmail) { |
|
498 | + if ($this->isEmail) { |
|
499 | 499 | return sprintf( |
500 | 500 | '<span class="link-scheme scheme-mailto">mailto:</span>'. |
501 | 501 | '<span class="link-host">%s</span>', |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | ); |
504 | 504 | } |
505 | 505 | |
506 | - if($this->isFragment) { |
|
506 | + if ($this->isFragment) { |
|
507 | 507 | return sprintf( |
508 | 508 | '<span class="link-fragment-sign">#</span>'. |
509 | 509 | '<span class="link-fragment-value">%s</span>', |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | ); |
512 | 512 | } |
513 | 513 | |
514 | - if($this->hasScheme()) |
|
514 | + if ($this->hasScheme()) |
|
515 | 515 | { |
516 | 516 | $result = sprintf( |
517 | 517 | '<span class="link-scheme scheme-%1$s">'. |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | |
524 | 524 | $result .= '<span class="link-component double-slashes">//</span>'; |
525 | 525 | |
526 | - if($this->hasUsername()) |
|
526 | + if ($this->hasUsername()) |
|
527 | 527 | { |
528 | 528 | $result .= sprintf( |
529 | 529 | '<span class="link-credentials">%s</span>'. |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ); |
536 | 536 | } |
537 | 537 | |
538 | - if($this->hasHost()) |
|
538 | + if ($this->hasHost()) |
|
539 | 539 | { |
540 | 540 | $result .= |
541 | 541 | sprintf( |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | ); |
545 | 545 | } |
546 | 546 | |
547 | - if($this->hasPort()) |
|
547 | + if ($this->hasPort()) |
|
548 | 548 | { |
549 | 549 | $result .= sprintf( |
550 | 550 | '<span class="link-component port-separator">:</span>'. |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | ); |
554 | 554 | } |
555 | 555 | |
556 | - if($this->hasPath()) |
|
556 | + if ($this->hasPath()) |
|
557 | 557 | { |
558 | 558 | $path = str_replace(array(';', '='), array(';<wbr>', '=<wbr>'), $this->getPath()); |
559 | 559 | $tokens = explode('/', $path); |
@@ -564,11 +564,11 @@ discard block |
||
564 | 564 | ); |
565 | 565 | } |
566 | 566 | |
567 | - if(!empty($this->params)) |
|
567 | + if (!empty($this->params)) |
|
568 | 568 | { |
569 | 569 | $tokens = array(); |
570 | 570 | |
571 | - foreach($this->params as $param => $value) |
|
571 | + foreach ($this->params as $param => $value) |
|
572 | 572 | { |
573 | 573 | $parts = sprintf( |
574 | 574 | '<span class="link-param-name">%s</span>'. |
@@ -586,10 +586,10 @@ discard block |
||
586 | 586 | $tag = ''; |
587 | 587 | |
588 | 588 | // is parameter exclusion enabled, and is this an excluded parameter? |
589 | - if($this->paramExclusion && isset($this->excludedParams[$param])) |
|
589 | + if ($this->paramExclusion && isset($this->excludedParams[$param])) |
|
590 | 590 | { |
591 | 591 | // display the excluded parameter, but highlight it |
592 | - if($this->highlightExcluded) |
|
592 | + if ($this->highlightExcluded) |
|
593 | 593 | { |
594 | 594 | $tooltip = $this->excludedParams[$param]; |
595 | 595 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | '<span class="link-component query-sign">?</span>'.implode('<span class="link-component param-separator">&</span>', $tokens); |
620 | 620 | } |
621 | 621 | |
622 | - if(isset($this->info['fragment'])) { |
|
622 | + if (isset($this->info['fragment'])) { |
|
623 | 623 | $result .= sprintf( |
624 | 624 | '<span class="link-fragment-sign">#</span>'. |
625 | 625 | '<span class="link-fragment">%s</span>', |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | |
643 | 643 | public function getErrorMessage() : string |
644 | 644 | { |
645 | - if(isset($this->error)) { |
|
645 | + if (isset($this->error)) { |
|
646 | 646 | return $this->error['message']; |
647 | 647 | } |
648 | 648 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | |
652 | 652 | public function getErrorCode() : int |
653 | 653 | { |
654 | - if(isset($this->error)) { |
|
654 | + if (isset($this->error)) { |
|
655 | 655 | return $this->error['code']; |
656 | 656 | } |
657 | 657 | |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | */ |
682 | 682 | public function getParams() : array |
683 | 683 | { |
684 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
684 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
685 | 685 | return $this->params; |
686 | 686 | } |
687 | 687 | |
688 | 688 | $keep = array(); |
689 | - foreach($this->params as $name => $value) { |
|
690 | - if(!isset($this->excludedParams[$name])) { |
|
689 | + foreach ($this->params as $name => $value) { |
|
690 | + if (!isset($this->excludedParams[$name])) { |
|
691 | 691 | $keep[$name] = $value; |
692 | 692 | } |
693 | 693 | } |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | */ |
718 | 718 | public function excludeParam(string $name, string $reason) : URLInfo |
719 | 719 | { |
720 | - if(!isset($this->excludedParams[$name])) |
|
720 | + if (!isset($this->excludedParams[$name])) |
|
721 | 721 | { |
722 | 722 | $this->excludedParams[$name] = $reason; |
723 | 723 | $this->setParamExclusion(); |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | */ |
739 | 739 | public function getType() : string |
740 | 740 | { |
741 | - if($this->isEmail) { |
|
741 | + if ($this->isEmail) { |
|
742 | 742 | return self::TYPE_EMAIL; |
743 | 743 | } |
744 | 744 | |
745 | - if($this->isFragment) { |
|
745 | + if ($this->isFragment) { |
|
746 | 746 | return self::TYPE_FRAGMENT; |
747 | 747 | } |
748 | 748 | |
749 | - if($this->isPhone) { |
|
749 | + if ($this->isPhone) { |
|
750 | 750 | return self::TYPE_PHONE; |
751 | 751 | } |
752 | 752 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | public function getTypeLabel() : string |
757 | 757 | { |
758 | - if(!isset(self::$typeLabels)) |
|
758 | + if (!isset(self::$typeLabels)) |
|
759 | 759 | { |
760 | 760 | self::$typeLabels = array( |
761 | 761 | self::TYPE_EMAIL => t('Email'), |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | |
768 | 768 | $type = $this->getType(); |
769 | 769 | |
770 | - if(!isset(self::$typeLabels[$type])) |
|
770 | + if (!isset(self::$typeLabels[$type])) |
|
771 | 771 | { |
772 | 772 | throw new BaseException( |
773 | 773 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | * @param bool $highlight |
788 | 788 | * @return URLInfo |
789 | 789 | */ |
790 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
790 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
791 | 791 | { |
792 | 792 | $this->highlightExcluded = $highlight; |
793 | 793 | return $this; |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @see URLInfo::isParamExclusionEnabled() |
836 | 836 | * @see URLInfo::setHighlightExcluded() |
837 | 837 | */ |
838 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
838 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
839 | 839 | { |
840 | 840 | $this->paramExclusion = $enabled; |
841 | 841 | return $this; |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | */ |
862 | 862 | public function containsExcludedParams() : bool |
863 | 863 | { |
864 | - if(empty($this->excludedParams)) { |
|
864 | + if (empty($this->excludedParams)) { |
|
865 | 865 | return false; |
866 | 866 | } |
867 | 867 | |
868 | 868 | $names = array_keys($this->params); |
869 | - foreach($names as $name) { |
|
870 | - if(isset($this->excludedParams[$name])) { |
|
869 | + foreach ($names as $name) { |
|
870 | + if (isset($this->excludedParams[$name])) { |
|
871 | 871 | return true; |
872 | 872 | } |
873 | 873 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | |
884 | 884 | public function offsetSet($offset, $value) |
885 | 885 | { |
886 | - if(in_array($offset, $this->infoKeys)) { |
|
886 | + if (in_array($offset, $this->infoKeys)) { |
|
887 | 887 | $this->info[$offset] = $value; |
888 | 888 | } |
889 | 889 | } |
@@ -900,11 +900,11 @@ discard block |
||
900 | 900 | |
901 | 901 | public function offsetGet($offset) |
902 | 902 | { |
903 | - if($offset === 'port') { |
|
903 | + if ($offset === 'port') { |
|
904 | 904 | return $this->getPort(); |
905 | 905 | } |
906 | 906 | |
907 | - if(in_array($offset, $this->infoKeys)) { |
|
907 | + if (in_array($offset, $this->infoKeys)) { |
|
908 | 908 | return $this->getInfoKey($offset); |
909 | 909 | } |
910 | 910 | |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | { |
916 | 916 | $cssFolder = realpath(__DIR__.'/../css'); |
917 | 917 | |
918 | - if($cssFolder === false) { |
|
918 | + if ($cssFolder === false) { |
|
919 | 919 | throw new BaseException( |
920 | 920 | 'Cannot find package CSS folder.', |
921 | 921 | null, |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $amount = substr_count($line, "\t") - $min; |
69 | 69 | $line = trim($line); |
70 | 70 | if ($amount >= 1) { |
71 | - $line = str_repeat("\t", $amount) . $line; |
|
71 | + $line = str_repeat("\t", $amount).$line; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $converted[] = $line; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | |
141 | 141 | // specifically handle zero |
142 | 142 | if ($seconds <= 0) { |
143 | - return '0 ' . t('seconds'); |
|
143 | + return '0 '.t('seconds'); |
|
144 | 144 | } |
145 | 145 | |
146 | - if($seconds < 1) { |
|
146 | + if ($seconds < 1) { |
|
147 | 147 | return t('less than a second'); |
148 | 148 | } |
149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | foreach ($units as $def) { |
152 | 152 | $quot = intval($seconds / $def['value']); |
153 | 153 | if ($quot) { |
154 | - $item = $quot . ' '; |
|
154 | + $item = $quot.' '; |
|
155 | 155 | if (abs($quot) > 1) { |
156 | 156 | $item .= $def['plural']; |
157 | 157 | } else { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | return $last; |
169 | 169 | } |
170 | 170 | |
171 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
171 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function duration2string($datefrom, $dateto = -1) |
187 | 187 | { |
188 | - if($datefrom instanceof \DateTime) { |
|
188 | + if ($datefrom instanceof \DateTime) { |
|
189 | 189 | $datefrom = ConvertHelper::date2timestamp($datefrom); |
190 | 190 | } |
191 | 191 | |
192 | - if($dateto instanceof \DateTime) { |
|
192 | + if ($dateto instanceof \DateTime) { |
|
193 | 193 | $dateto = ConvertHelper::date2timestamp($dateto); |
194 | 194 | } |
195 | 195 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $difference = $dateto - $datefrom; |
210 | 210 | |
211 | 211 | $future = false; |
212 | - if($difference < 0) { |
|
212 | + if ($difference < 0) { |
|
213 | 213 | $difference = $difference * -1; |
214 | 214 | $future = true; |
215 | 215 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $datediff--; |
288 | 288 | } |
289 | 289 | |
290 | - if($future) { |
|
290 | + if ($future) { |
|
291 | 291 | $res = ($datediff == 1) ? t('In one month', $datediff) : t('In %1s months', $datediff); |
292 | 292 | } else { |
293 | 293 | $res = ($datediff == 1) ? t('One month ago', $datediff) : t('%1s months ago', $datediff); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | case "y": |
298 | 298 | $datediff = floor($difference / 60 / 60 / 24 / 365); |
299 | - if($future) { |
|
299 | + if ($future) { |
|
300 | 300 | $res = ($datediff == 1) ? t('In one year', $datediff) : t('In %1s years', $datediff); |
301 | 301 | } else { |
302 | 302 | $res = ($datediff == 1) ? t('One year ago', $datediff) : t('%1s years ago', $datediff); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | case "d": |
307 | 307 | $datediff = floor($difference / 60 / 60 / 24); |
308 | - if($future) { |
|
308 | + if ($future) { |
|
309 | 309 | $res = ($datediff == 1) ? t('In one day', $datediff) : t('In %1s days', $datediff); |
310 | 310 | } else { |
311 | 311 | $res = ($datediff == 1) ? t('One day ago', $datediff) : t('%1s days ago', $datediff); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | case "ww": |
316 | 316 | $datediff = floor($difference / 60 / 60 / 24 / 7); |
317 | - if($future) { |
|
317 | + if ($future) { |
|
318 | 318 | $res = ($datediff == 1) ? t('In one week', $datediff) : t('In %1s weeks', $datediff); |
319 | 319 | } else { |
320 | 320 | $res = ($datediff == 1) ? t('One week ago', $datediff) : t('%1s weeks ago', $datediff); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | case "h": |
325 | 325 | $datediff = floor($difference / 60 / 60); |
326 | - if($future) { |
|
326 | + if ($future) { |
|
327 | 327 | $res = ($datediff == 1) ? t('In one hour', $datediff) : t('In %1s hours', $datediff); |
328 | 328 | } else { |
329 | 329 | $res = ($datediff == 1) ? t('One hour ago', $datediff) : t('%1s hours ago', $datediff); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | case "n": |
334 | 334 | $datediff = floor($difference / 60); |
335 | - if($future) { |
|
335 | + if ($future) { |
|
336 | 336 | $res = ($datediff == 1) ? t('In one minute', $datediff) : t('In %1s minutes', $datediff); |
337 | 337 | } else { |
338 | 338 | $res = ($datediff == 1) ? t('One minute ago', $datediff) : t('%1s minutes ago', $datediff); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | case "s": |
343 | 343 | $datediff = $difference; |
344 | - if($future) { |
|
344 | + if ($future) { |
|
345 | 345 | $res = ($datediff == 1) ? t('In one second', $datediff) : t('In %1s seconds', $datediff); |
346 | 346 | } else { |
347 | 347 | $res = ($datediff == 1) ? t('One second ago', $datediff) : t('%1s seconds ago', $datediff); |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | return $geshi->parse_code(); |
365 | 365 | } |
366 | 366 | |
367 | - public static function highlight_xml($xml, $formatSource=false) |
|
367 | + public static function highlight_xml($xml, $formatSource = false) |
|
368 | 368 | { |
369 | - if($formatSource) |
|
369 | + if ($formatSource) |
|
370 | 370 | { |
371 | 371 | $dom = new \DOMDocument(); |
372 | 372 | $dom->loadXML($xml); |
@@ -404,22 +404,22 @@ discard block |
||
404 | 404 | $terabyte = $gigabyte * 1024; |
405 | 405 | |
406 | 406 | if (($bytes >= 0) && ($bytes < $kilobyte)) { |
407 | - return $bytes . ' ' . t('B'); |
|
407 | + return $bytes.' '.t('B'); |
|
408 | 408 | |
409 | 409 | } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { |
410 | - return round($bytes / $kilobyte, $precision) . ' ' . t('Kb'); |
|
410 | + return round($bytes / $kilobyte, $precision).' '.t('Kb'); |
|
411 | 411 | |
412 | 412 | } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { |
413 | - return round($bytes / $megabyte, $precision) . ' ' . t('Mb'); |
|
413 | + return round($bytes / $megabyte, $precision).' '.t('Mb'); |
|
414 | 414 | |
415 | 415 | } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { |
416 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Gb'); |
|
416 | + return round($bytes / $gigabyte, $precision).' '.t('Gb'); |
|
417 | 417 | |
418 | 418 | } elseif ($bytes >= $terabyte) { |
419 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Tb'); |
|
419 | + return round($bytes / $gigabyte, $precision).' '.t('Tb'); |
|
420 | 420 | } |
421 | 421 | |
422 | - return $bytes . ' ' . t('B'); |
|
422 | + return $bytes.' '.t('B'); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -439,34 +439,34 @@ discard block |
||
439 | 439 | return $text; |
440 | 440 | } |
441 | 441 | |
442 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
442 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
443 | 443 | |
444 | 444 | return $text; |
445 | 445 | } |
446 | 446 | |
447 | - public static function var_dump($var, $html=true) |
|
447 | + public static function var_dump($var, $html = true) |
|
448 | 448 | { |
449 | 449 | $info = parseVariable($var); |
450 | 450 | |
451 | - if($html) { |
|
451 | + if ($html) { |
|
452 | 452 | return $info->toHTML(); |
453 | 453 | } |
454 | 454 | |
455 | 455 | return $info->toString(); |
456 | 456 | } |
457 | 457 | |
458 | - public static function print_r($var, $return=false, $html=true) |
|
458 | + public static function print_r($var, $return = false, $html = true) |
|
459 | 459 | { |
460 | 460 | $result = self::var_dump($var, $html); |
461 | 461 | |
462 | - if($html) { |
|
462 | + if ($html) { |
|
463 | 463 | $result = |
464 | 464 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
465 | 465 | $result. |
466 | 466 | '</pre>'; |
467 | 467 | } |
468 | 468 | |
469 | - if($return) { |
|
469 | + if ($return) { |
|
470 | 470 | return $result; |
471 | 471 | } |
472 | 472 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | public static function string2bool($string) |
488 | 488 | { |
489 | - if($string === '' || $string === null) { |
|
489 | + if ($string === '' || $string === null) { |
|
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false) |
542 | 542 | { |
543 | 543 | $today = new \DateTime(); |
544 | - if($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
544 | + if ($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
545 | 545 | $label = t('Today'); |
546 | 546 | } else { |
547 | - $label = $date->format('d') . '. ' . self::month2string($date->format('m'), $shortMonth) . ' '; |
|
547 | + $label = $date->format('d').'. '.self::month2string($date->format('m'), $shortMonth).' '; |
|
548 | 548 | if ($date->format('Y') != date('Y')) { |
549 | 549 | $label .= $date->format('Y'); |
550 | 550 | } |
@@ -635,28 +635,28 @@ discard block |
||
635 | 635 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
636 | 636 | |
637 | 637 | $stack = array(); |
638 | - foreach(self::$controlChars as $char) |
|
638 | + foreach (self::$controlChars as $char) |
|
639 | 639 | { |
640 | 640 | $tokens = explode('-', $char); |
641 | 641 | $start = $tokens[0]; |
642 | 642 | $end = $tokens[1]; |
643 | 643 | $prefix = substr($start, 0, 3); |
644 | 644 | $range = array(); |
645 | - foreach($hexAlphabet as $number) { |
|
645 | + foreach ($hexAlphabet as $number) { |
|
646 | 646 | $range[] = $prefix.$number; |
647 | 647 | } |
648 | 648 | |
649 | 649 | $use = false; |
650 | - foreach($range as $number) { |
|
651 | - if($number == $start) { |
|
650 | + foreach ($range as $number) { |
|
651 | + if ($number == $start) { |
|
652 | 652 | $use = true; |
653 | 653 | } |
654 | 654 | |
655 | - if($use) { |
|
655 | + if ($use) { |
|
656 | 656 | $stack[] = $number; |
657 | 657 | } |
658 | 658 | |
659 | - if($number == $end) { |
|
659 | + if ($number == $end) { |
|
660 | 660 | break; |
661 | 661 | } |
662 | 662 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $chars = self::getControlCharactersAsHex(); |
678 | 678 | |
679 | 679 | $result = array(); |
680 | - foreach($chars as $char) { |
|
680 | + foreach ($chars as $char) { |
|
681 | 681 | $result[] = hex2bin($char); |
682 | 682 | } |
683 | 683 | |
@@ -695,14 +695,14 @@ discard block |
||
695 | 695 | $chars = self::getControlCharactersAsHex(); |
696 | 696 | |
697 | 697 | $result = array(); |
698 | - foreach($chars as $char) { |
|
698 | + foreach ($chars as $char) { |
|
699 | 699 | $result[] = '\u'.strtolower($char); |
700 | 700 | } |
701 | 701 | |
702 | 702 | return $result; |
703 | 703 | } |
704 | 704 | |
705 | - protected static $controlChars = array( |
|
705 | + protected static $controlChars = array( |
|
706 | 706 | '0000-0008', // control chars |
707 | 707 | '000E-000F', // control chars |
708 | 708 | '0010-001F', // control chars |
@@ -724,11 +724,11 @@ discard block |
||
724 | 724 | */ |
725 | 725 | public static function stripControlCharacters($string) |
726 | 726 | { |
727 | - if(empty($string)) { |
|
727 | + if (empty($string)) { |
|
728 | 728 | return $string; |
729 | 729 | } |
730 | 730 | |
731 | - if(!is_string($string)) { |
|
731 | + if (!is_string($string)) { |
|
732 | 732 | throw new ConvertHelper_Exception( |
733 | 733 | 'Subject is not a string', |
734 | 734 | sprintf( |
@@ -740,14 +740,14 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | // create the regex from the unicode characters list |
743 | - if(!isset(self::$controlCharsRegex)) |
|
743 | + if (!isset(self::$controlCharsRegex)) |
|
744 | 744 | { |
745 | 745 | $chars = self::getControlCharactersAsHex(); |
746 | 746 | |
747 | 747 | // we use the notation \x{0000} to specify the unicode character key |
748 | 748 | // in the regular expression. |
749 | 749 | $stack = array(); |
750 | - foreach($chars as $char) { |
|
750 | + foreach ($chars as $char) { |
|
751 | 751 | $stack[] = '\x{'.$char.'}'; |
752 | 752 | } |
753 | 753 | |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | $ordInt = ord($octet); |
782 | 782 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
783 | 783 | $ordHex = base_convert($ordInt, 10, 16); |
784 | - $output .= '\x' . $ordHex; |
|
784 | + $output .= '\x'.$ordHex; |
|
785 | 785 | } |
786 | 786 | return $output; |
787 | 787 | } |
@@ -813,19 +813,19 @@ discard block |
||
813 | 813 | |
814 | 814 | protected static function convertScalarForComparison($scalar) |
815 | 815 | { |
816 | - if($scalar === '' || is_null($scalar)) { |
|
816 | + if ($scalar === '' || is_null($scalar)) { |
|
817 | 817 | return null; |
818 | 818 | } |
819 | 819 | |
820 | - if(is_bool($scalar)) { |
|
820 | + if (is_bool($scalar)) { |
|
821 | 821 | return self::bool2string($scalar); |
822 | 822 | } |
823 | 823 | |
824 | - if(is_array($scalar)) { |
|
824 | + if (is_array($scalar)) { |
|
825 | 825 | $scalar = md5(serialize($scalar)); |
826 | 826 | } |
827 | 827 | |
828 | - if($scalar !== null && !is_scalar($scalar)) { |
|
828 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
829 | 829 | throw new ConvertHelper_Exception( |
830 | 830 | 'Not a scalar value in comparison', |
831 | 831 | null, |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | public static function bool2string($boolean, $yesno = false) |
875 | 875 | { |
876 | 876 | // allow 'yes', 'true', 'no', 'false' string notations as well |
877 | - if(!is_bool($boolean)) { |
|
877 | + if (!is_bool($boolean)) { |
|
878 | 878 | $boolean = self::string2bool($boolean); |
879 | 879 | } |
880 | 880 | |
@@ -915,15 +915,15 @@ discard block |
||
915 | 915 | public static function array2attributeString($array) |
916 | 916 | { |
917 | 917 | $tokens = array(); |
918 | - foreach($array as $attr => $value) { |
|
919 | - if($value == '' || $value == null) { |
|
918 | + foreach ($array as $attr => $value) { |
|
919 | + if ($value == '' || $value == null) { |
|
920 | 920 | continue; |
921 | 921 | } |
922 | 922 | |
923 | 923 | $tokens[] = $attr.'="'.$value.'"'; |
924 | 924 | } |
925 | 925 | |
926 | - if(empty($tokens)) { |
|
926 | + if (empty($tokens)) { |
|
927 | 927 | return ''; |
928 | 928 | } |
929 | 929 | |
@@ -938,10 +938,10 @@ discard block |
||
938 | 938 | * @param string $string |
939 | 939 | * @return string |
940 | 940 | */ |
941 | - public static function string2attributeJS($string, $quoted=true) |
|
941 | + public static function string2attributeJS($string, $quoted = true) |
|
942 | 942 | { |
943 | 943 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
944 | - if($quoted) { |
|
944 | + if ($quoted) { |
|
945 | 945 | $converted = "'".$converted."'"; |
946 | 946 | } |
947 | 947 | |
@@ -959,11 +959,11 @@ discard block |
||
959 | 959 | */ |
960 | 960 | public static function isBoolean($value) |
961 | 961 | { |
962 | - if(is_bool($value)) { |
|
962 | + if (is_bool($value)) { |
|
963 | 963 | return true; |
964 | 964 | } |
965 | 965 | |
966 | - if(!is_scalar($value)) { |
|
966 | + if (!is_scalar($value)) { |
|
967 | 967 | return false; |
968 | 968 | } |
969 | 969 | |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | public static function array2styleString($subject) |
980 | 980 | { |
981 | 981 | $tokens = array(); |
982 | - foreach($subject as $name => $value) { |
|
982 | + foreach ($subject as $name => $value) { |
|
983 | 983 | $tokens[] = $name.':'.$value; |
984 | 984 | } |
985 | 985 | |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | * @param string $regex |
1045 | 1045 | * @return array |
1046 | 1046 | */ |
1047 | - public static function regex2js($regex, $return=self::JS_REGEX_OBJECT) |
|
1047 | + public static function regex2js($regex, $return = self::JS_REGEX_OBJECT) |
|
1048 | 1048 | { |
1049 | 1049 | $regex = trim($regex); |
1050 | 1050 | $separator = substr($regex, 0, 1); |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | array_shift($parts); |
1053 | 1053 | |
1054 | 1054 | $modifiers = array_pop($parts); |
1055 | - if($modifiers == $separator) { |
|
1055 | + if ($modifiers == $separator) { |
|
1056 | 1056 | $modifiers = ''; |
1057 | 1057 | } |
1058 | 1058 | |
@@ -1068,14 +1068,14 @@ discard block |
||
1068 | 1068 | // convert the anchors that are not supported in js regexes |
1069 | 1069 | $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format); |
1070 | 1070 | |
1071 | - if($return==self::JS_REGEX_JSON) { |
|
1071 | + if ($return == self::JS_REGEX_JSON) { |
|
1072 | 1072 | return json_encode(array( |
1073 | 1073 | 'format' => $format, |
1074 | 1074 | 'modifiers' => $modifiers |
1075 | 1075 | )); |
1076 | 1076 | } |
1077 | 1077 | |
1078 | - if(!empty($modifiers)) { |
|
1078 | + if (!empty($modifiers)) { |
|
1079 | 1079 | return sprintf( |
1080 | 1080 | 'new RegExp(%s, %s)', |
1081 | 1081 | json_encode($format), |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | public static function stripUTFBom($string) |
1099 | 1099 | { |
1100 | 1100 | $boms = FileHelper::getUTFBOMs(); |
1101 | - foreach($boms as $bomChars) { |
|
1101 | + foreach ($boms as $bomChars) { |
|
1102 | 1102 | $length = mb_strlen($bomChars); |
1103 | 1103 | $text = mb_substr($string, 0, $length); |
1104 | - if($text==$bomChars) { |
|
1104 | + if ($text == $bomChars) { |
|
1105 | 1105 | return mb_substr($string, $length); |
1106 | 1106 | } |
1107 | 1107 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | */ |
1119 | 1119 | public static function string2utf8($string) |
1120 | 1120 | { |
1121 | - if(!self::isStringASCII($string)) { |
|
1121 | + if (!self::isStringASCII($string)) { |
|
1122 | 1122 | return \ForceUTF8\Encoding::toUTF8($string); |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | */ |
1137 | 1137 | public static function isStringASCII($string) |
1138 | 1138 | { |
1139 | - if($string === '' || $string === NULL) { |
|
1139 | + if ($string === '' || $string === NULL) { |
|
1140 | 1140 | return true; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - if(!is_string($string)) { |
|
1143 | + if (!is_string($string)) { |
|
1144 | 1144 | return false; |
1145 | 1145 | } |
1146 | 1146 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * @param array $options |
1175 | 1175 | * @return float |
1176 | 1176 | */ |
1177 | - public static function matchString($source, $target, $options=array()) |
|
1177 | + public static function matchString($source, $target, $options = array()) |
|
1178 | 1178 | { |
1179 | 1179 | $defaults = array( |
1180 | 1180 | 'maxLevenshtein' => 10, |
@@ -1184,12 +1184,12 @@ discard block |
||
1184 | 1184 | $options = array_merge($defaults, $options); |
1185 | 1185 | |
1186 | 1186 | // avoid doing this via levenshtein |
1187 | - if($source == $target) { |
|
1187 | + if ($source == $target) { |
|
1188 | 1188 | return 100; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | $diff = levenshtein($source, $target); |
1192 | - if($diff > $options['maxLevenshtein']) { |
|
1192 | + if ($diff > $options['maxLevenshtein']) { |
|
1193 | 1193 | return 0; |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1203,8 +1203,8 @@ discard block |
||
1203 | 1203 | |
1204 | 1204 | $offset = 0; |
1205 | 1205 | $keep = array(); |
1206 | - foreach($tokens as $token) { |
|
1207 | - if($interval->$token > 0) { |
|
1206 | + foreach ($tokens as $token) { |
|
1207 | + if ($interval->$token > 0) { |
|
1208 | 1208 | $keep = array_slice($tokens, $offset); |
1209 | 1209 | break; |
1210 | 1210 | } |
@@ -1213,16 +1213,16 @@ discard block |
||
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | $parts = array(); |
1216 | - foreach($keep as $token) |
|
1216 | + foreach ($keep as $token) |
|
1217 | 1217 | { |
1218 | 1218 | $value = $interval->$token; |
1219 | 1219 | $label = ''; |
1220 | 1220 | |
1221 | 1221 | $suffix = 'p'; |
1222 | - if($value == 1) { $suffix = 's'; } |
|
1222 | + if ($value == 1) { $suffix = 's'; } |
|
1223 | 1223 | $token .= $suffix; |
1224 | 1224 | |
1225 | - switch($token) { |
|
1225 | + switch ($token) { |
|
1226 | 1226 | case 'ys': $label = t('1 year'); break; |
1227 | 1227 | case 'yp': $label = t('%1$s years', $value); break; |
1228 | 1228 | case 'ms': $label = t('1 month'); break; |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $parts[] = $label; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - if(count($parts) == 1) { |
|
1243 | + if (count($parts) == 1) { |
|
1244 | 1244 | return $parts[0]; |
1245 | 1245 | } |
1246 | 1246 | |
@@ -1265,23 +1265,23 @@ discard block |
||
1265 | 1265 | * @param string $unit |
1266 | 1266 | * @return integer |
1267 | 1267 | */ |
1268 | - public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) |
|
1268 | + public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) |
|
1269 | 1269 | { |
1270 | 1270 | $total = $interval->format('%a'); |
1271 | 1271 | if ($unit == self::INTERVAL_DAYS) { |
1272 | 1272 | return $total; |
1273 | 1273 | } |
1274 | 1274 | |
1275 | - $total = ($total * 24) + ($interval->h ); |
|
1275 | + $total = ($total * 24) + ($interval->h); |
|
1276 | 1276 | if ($unit == self::INTERVAL_HOURS) { |
1277 | 1277 | return $total; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | - $total = ($total * 60) + ($interval->i ); |
|
1280 | + $total = ($total * 60) + ($interval->i); |
|
1281 | 1281 | if ($unit == self::INTERVAL_MINUTES) |
1282 | 1282 | return $total; |
1283 | 1283 | |
1284 | - $total = ($total * 60) + ($interval->s ); |
|
1284 | + $total = ($total * 60) + ($interval->s); |
|
1285 | 1285 | if ($unit == self::INTERVAL_SECONDS) |
1286 | 1286 | return $total; |
1287 | 1287 | |
@@ -1309,13 +1309,13 @@ discard block |
||
1309 | 1309 | * @param string $short |
1310 | 1310 | * @return string|NULL |
1311 | 1311 | */ |
1312 | - public static function date2dayName(\DateTime $date, $short=false) |
|
1312 | + public static function date2dayName(\DateTime $date, $short = false) |
|
1313 | 1313 | { |
1314 | 1314 | $day = $date->format('l'); |
1315 | 1315 | $invariant = self::getDayNamesInvariant(); |
1316 | 1316 | |
1317 | 1317 | $idx = array_search($day, $invariant); |
1318 | - if($idx !== false) { |
|
1318 | + if ($idx !== false) { |
|
1319 | 1319 | $localized = self::getDayNames($short); |
1320 | 1320 | return $localized[$idx]; |
1321 | 1321 | } |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | * @param string $short |
1339 | 1339 | * @return string[] |
1340 | 1340 | */ |
1341 | - public static function getDayNames($short=false) |
|
1341 | + public static function getDayNames($short = false) |
|
1342 | 1342 | { |
1343 | - if($short) { |
|
1344 | - if(!isset(self::$daysShort)) { |
|
1343 | + if ($short) { |
|
1344 | + if (!isset(self::$daysShort)) { |
|
1345 | 1345 | self::$daysShort = array( |
1346 | 1346 | t('Mon'), |
1347 | 1347 | t('Tue'), |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | return self::$daysShort; |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - if(!isset(self::$days)) { |
|
1359 | + if (!isset(self::$days)) { |
|
1360 | 1360 | self::$days = array( |
1361 | 1361 | t('Monday'), |
1362 | 1362 | t('Tuesday'), |
@@ -1381,17 +1381,17 @@ discard block |
||
1381 | 1381 | */ |
1382 | 1382 | public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null) |
1383 | 1383 | { |
1384 | - if(empty($list)) { |
|
1384 | + if (empty($list)) { |
|
1385 | 1385 | return ''; |
1386 | 1386 | } |
1387 | 1387 | |
1388 | - if(empty($conjunction)) { |
|
1388 | + if (empty($conjunction)) { |
|
1389 | 1389 | $conjunction = t('and'); |
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | $last = array_pop($list); |
1393 | - if($list) { |
|
1394 | - return implode($sep, $list) . $conjunction . ' ' . $last; |
|
1393 | + if ($list) { |
|
1394 | + return implode($sep, $list).$conjunction.' '.$last; |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | return $last; |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | */ |
1419 | 1419 | public static function isStringHTML($string) |
1420 | 1420 | { |
1421 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
1421 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
1422 | 1422 | return true; |
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | $decoded = html_entity_decode($string); |
1426 | - if($decoded !== $string) { |
|
1426 | + if ($decoded !== $string) { |
|
1427 | 1427 | return true; |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | // extract parameter names from the query string |
1561 | 1561 | $result = array(); |
1562 | 1562 | preg_match_all('/&?([^&]+)=.*/sixU', $queryString, $result, PREG_PATTERN_ORDER); |
1563 | - if(isset($result[1])) { |
|
1563 | + if (isset($result[1])) { |
|
1564 | 1564 | $paramNames = $result[1]; |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1581,12 +1581,12 @@ discard block |
||
1581 | 1581 | // possible naming conflicts like having both parameters "foo.bar" |
1582 | 1582 | // and "foo_bar" in the query string: since "foo.bar" would be converted |
1583 | 1583 | // to "foo_bar", one of the two would be replaced. |
1584 | - if($fixRequired) |
|
1584 | + if ($fixRequired) |
|
1585 | 1585 | { |
1586 | 1586 | $counter = 1; |
1587 | 1587 | $table = array(); |
1588 | 1588 | $placeholders = array(); |
1589 | - foreach($paramNames as $paramName) |
|
1589 | + foreach ($paramNames as $paramName) |
|
1590 | 1590 | { |
1591 | 1591 | // create a unique placeholder name |
1592 | 1592 | $placeholder = '__PLACEHOLDER'.$counter.'__'; |
@@ -1616,13 +1616,13 @@ discard block |
||
1616 | 1616 | parse_str($queryString, $parsed); |
1617 | 1617 | |
1618 | 1618 | // do any of the parameter names need to be fixed? |
1619 | - if(!$fixRequired) { |
|
1619 | + if (!$fixRequired) { |
|
1620 | 1620 | return $parsed; |
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | $keep = array(); |
1624 | 1624 | |
1625 | - foreach($parsed as $name => $value) |
|
1625 | + foreach ($parsed as $name => $value) |
|
1626 | 1626 | { |
1627 | 1627 | $keep[$table[$name]] = $value; |
1628 | 1628 | } |
@@ -1642,14 +1642,14 @@ discard block |
||
1642 | 1642 | * @param bool $caseInsensitive |
1643 | 1643 | * @return ConvertHelper_StringMatch[] |
1644 | 1644 | */ |
1645 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
|
1645 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false) |
|
1646 | 1646 | { |
1647 | - if($needle === '') { |
|
1647 | + if ($needle === '') { |
|
1648 | 1648 | return array(); |
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | $function = 'mb_strpos'; |
1652 | - if($caseInsensitive) { |
|
1652 | + if ($caseInsensitive) { |
|
1653 | 1653 | $function = 'mb_stripos'; |
1654 | 1654 | } |
1655 | 1655 | |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | $positions = array(); |
1658 | 1658 | $length = mb_strlen($needle); |
1659 | 1659 | |
1660 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
1660 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
1661 | 1661 | { |
1662 | 1662 | $match = mb_substr($haystack, $pos, $length); |
1663 | 1663 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -1677,7 +1677,7 @@ discard block |
||
1677 | 1677 | */ |
1678 | 1678 | public static function explodeTrim(string $delimiter, string $string) : array |
1679 | 1679 | { |
1680 | - if(empty($string) || empty($delimiter)) { |
|
1680 | + if (empty($string) || empty($delimiter)) { |
|
1681 | 1681 | return array(); |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1685,8 +1685,8 @@ discard block |
||
1685 | 1685 | $tokens = array_map('trim', $tokens); |
1686 | 1686 | |
1687 | 1687 | $keep = array(); |
1688 | - foreach($tokens as $token) { |
|
1689 | - if($token !== '') { |
|
1688 | + foreach ($tokens as $token) { |
|
1689 | + if ($token !== '') { |
|
1690 | 1690 | $keep[] = $token; |
1691 | 1691 | } |
1692 | 1692 | } |
@@ -1704,11 +1704,11 @@ discard block |
||
1704 | 1704 | */ |
1705 | 1705 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
1706 | 1706 | { |
1707 | - if(empty($subjectString)) { |
|
1707 | + if (empty($subjectString)) { |
|
1708 | 1708 | return null; |
1709 | 1709 | } |
1710 | 1710 | |
1711 | - if(!isset(self::$eolChars)) |
|
1711 | + if (!isset(self::$eolChars)) |
|
1712 | 1712 | { |
1713 | 1713 | self::$eolChars = array( |
1714 | 1714 | array( |
@@ -1736,18 +1736,18 @@ discard block |
||
1736 | 1736 | |
1737 | 1737 | $max = 0; |
1738 | 1738 | $results = array(); |
1739 | - foreach(self::$eolChars as $def) |
|
1739 | + foreach (self::$eolChars as $def) |
|
1740 | 1740 | { |
1741 | 1741 | $amount = substr_count($subjectString, $def['char']); |
1742 | 1742 | |
1743 | - if($amount > $max) |
|
1743 | + if ($amount > $max) |
|
1744 | 1744 | { |
1745 | 1745 | $max = $amount; |
1746 | 1746 | $results[] = $def; |
1747 | 1747 | } |
1748 | 1748 | } |
1749 | 1749 | |
1750 | - if(empty($results)) { |
|
1750 | + if (empty($results)) { |
|
1751 | 1751 | return null; |
1752 | 1752 | } |
1753 | 1753 | |
@@ -1767,9 +1767,9 @@ discard block |
||
1767 | 1767 | */ |
1768 | 1768 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
1769 | 1769 | { |
1770 | - foreach($keys as $key) |
|
1770 | + foreach ($keys as $key) |
|
1771 | 1771 | { |
1772 | - if(array_key_exists($key, $array)) { |
|
1772 | + if (array_key_exists($key, $array)) { |
|
1773 | 1773 | unset($array[$key]); |
1774 | 1774 | } |
1775 | 1775 | } |
@@ -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 |