Test Failed
Push — master ( fdf3d2...9d70d1 )
by Sebastian
04:37
created
src/ImageHelper/Size.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,23 +18,23 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/CSVHelper.php 2 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
         
51 51
     }
52 52
 
53
-   /**
54
-    * Creates and returns a new instance of the CSV builder which
55
-    * can be used to build CSV from scratch.
56
-    * 
57
-    * @return CSVHelper_Builder
58
-    */
53
+    /**
54
+     * Creates and returns a new instance of the CSV builder which
55
+     * can be used to build CSV from scratch.
56
+     * 
57
+     * @return CSVHelper_Builder
58
+     */
59 59
     public static function createBuilder()
60 60
     {
61 61
         return new CSVHelper_Builder();
62 62
     }
63 63
 
64
-   /**
65
-    * @var string
66
-    */
64
+    /**
65
+     * @var string
66
+     */
67 67
     protected $csv = '';
68 68
     
69 69
     protected $data = array();
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     
73 73
     protected $headersPosition = self::HEADERS_NONE;
74 74
     
75
-   /**
76
-    * Loads CSV data from a string. 
77
-    * 
78
-    * Note: Use the {@link hasErrors()} method to 
79
-    * check if the string could be parsed correctly
80
-    * afterwards.
81
-    * 
82
-    * @param string $string
83
-    * @return CSVHelper
84
-    */
75
+    /**
76
+     * Loads CSV data from a string. 
77
+     * 
78
+     * Note: Use the {@link hasErrors()} method to 
79
+     * check if the string could be parsed correctly
80
+     * afterwards.
81
+     * 
82
+     * @param string $string
83
+     * @return CSVHelper
84
+     */
85 85
     public function loadString($string)
86 86
     {
87 87
         // remove any UTF byte order marks that may still be present in the string
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
         return $this;
96 96
     }
97 97
     
98
-   /**
99
-    * Loads CSV data from a file.
100
-    * 
101
-    * Note: Use the {@link hasErrors()} method to 
102
-    * check if the string could be parsed correctly
103
-    * afterwards.
104
-    * 
105
-    * @param string $file
106
-    * @throws FileHelper_Exception
107
-    * @return CSVHelper
108
-    * 
109
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
110
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
111
-    */
98
+    /**
99
+     * Loads CSV data from a file.
100
+     * 
101
+     * Note: Use the {@link hasErrors()} method to 
102
+     * check if the string could be parsed correctly
103
+     * afterwards.
104
+     * 
105
+     * @param string $file
106
+     * @throws FileHelper_Exception
107
+     * @return CSVHelper
108
+     * 
109
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
110
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
111
+     */
112 112
     public function loadFile(string $file) : CSVHelper
113 113
     {
114 114
         $csv = FileHelper::readContents($file);
@@ -122,28 +122,28 @@  discard block
 block discarded – undo
122 122
     
123 123
     protected $rowCount = 0;
124 124
     
125
-   /**
126
-    * Specifies that headers are positioned on top, horizontally.
127
-    * @return CSVHelper
128
-    */
125
+    /**
126
+     * Specifies that headers are positioned on top, horizontally.
127
+     * @return CSVHelper
128
+     */
129 129
     public function setHeadersTop()
130 130
     {
131 131
         return $this->setHeadersPosition(self::HEADERS_TOP);
132 132
     }
133 133
     
134
-   /**
135
-    * Specifies that headers are positioned on the left, vertically.
136
-    * @return CSVHelper
137
-    */
134
+    /**
135
+     * Specifies that headers are positioned on the left, vertically.
136
+     * @return CSVHelper
137
+     */
138 138
     public function setHeadersLeft()
139 139
     {
140 140
         return $this->setHeadersPosition(self::HEADERS_LEFT);
141 141
     }
142 142
     
143
-   /**
144
-    * Specifies that there are no headers in the file (default).
145
-    * @return CSVHelper
146
-    */
143
+    /**
144
+     * Specifies that there are no headers in the file (default).
145
+     * @return CSVHelper
146
+     */
147 147
     public function setHeadersNone()
148 148
     {
149 149
         return $this->setHeadersPosition(self::HEADERS_NONE);
@@ -173,18 +173,18 @@  discard block
 block discarded – undo
173 173
         return false;
174 174
     }
175 175
     
176
-   /**
177
-    * Specifies where the headers are positioned in the
178
-    * CSV, or turns them off entirely. Use the class constants
179
-    * to ensure the value is correct.
180
-    * 
181
-    * @param string $position
182
-    * @throws CSVHelper_Exception
183
-    * @return CSVHelper
184
-    * @see CSVHelper::HEADERS_LEFT
185
-    * @see CSVHelper::HEADERS_TOP
186
-    * @see CSVHelper::HEADERS_NONE
187
-    */
176
+    /**
177
+     * Specifies where the headers are positioned in the
178
+     * CSV, or turns them off entirely. Use the class constants
179
+     * to ensure the value is correct.
180
+     * 
181
+     * @param string $position
182
+     * @throws CSVHelper_Exception
183
+     * @return CSVHelper
184
+     * @see CSVHelper::HEADERS_LEFT
185
+     * @see CSVHelper::HEADERS_TOP
186
+     * @see CSVHelper::HEADERS_NONE
187
+     */
188 188
     public function setHeadersPosition($position)
189 189
     {
190 190
         $validPositions = array(
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
         return $this;
212 212
     }
213 213
     
214
-   /**
215
-    * Resets all internal data, allowing to start entirely anew
216
-    * with a new file, or to start building a new CSV file from
217
-    * scratch.
218
-    * 
219
-    * @return CSVHelper
220
-    */
214
+    /**
215
+     * Resets all internal data, allowing to start entirely anew
216
+     * with a new file, or to start building a new CSV file from
217
+     * scratch.
218
+     * 
219
+     * @return CSVHelper
220
+     */
221 221
     public function reset()
222 222
     {
223 223
         $this->data = array();
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
         return $this->data;
235 235
     }
236 236
     
237
-   /**
238
-    * Retrieves the row at the specified index.
239
-    * If there is no data at the index, this will
240
-    * return an array populated with empty strings
241
-    * for all available columns.
242
-    * 
243
-    * Tip: Use the {@link rowExists()} method to check
244
-    * whether the specified row exists.
245
-    * 
246
-    * @param integer $index
247
-    * @return array()
248
-    * @see rowExists()
249
-    */
237
+    /**
238
+     * Retrieves the row at the specified index.
239
+     * If there is no data at the index, this will
240
+     * return an array populated with empty strings
241
+     * for all available columns.
242
+     * 
243
+     * Tip: Use the {@link rowExists()} method to check
244
+     * whether the specified row exists.
245
+     * 
246
+     * @param integer $index
247
+     * @return array()
248
+     * @see rowExists()
249
+     */
250 250
     public function getRow($index)
251 251
     {
252 252
         if(isset($this->data[$index])) {
@@ -256,63 +256,63 @@  discard block
 block discarded – undo
256 256
         return array_fill(0, $this->rowCount, '');
257 257
     }
258 258
     
259
-   /**
260
-    * Checks whether the specified row exists in the data set.
261
-    * @param integer $index
262
-    * @return boolean
263
-    */
259
+    /**
260
+     * Checks whether the specified row exists in the data set.
261
+     * @param integer $index
262
+     * @return boolean
263
+     */
264 264
     public function rowExists($index)
265 265
     {
266 266
         return isset($this->data[$index]);
267 267
     }
268 268
     
269
-   /**
270
-    * Counts the amount of rows in the parsed CSV,
271
-    * excluding the headers if any, depending on 
272
-    * their position.
273
-    * 
274
-    * @return integer
275
-    */
269
+    /**
270
+     * Counts the amount of rows in the parsed CSV,
271
+     * excluding the headers if any, depending on 
272
+     * their position.
273
+     * 
274
+     * @return integer
275
+     */
276 276
     public function countRows()
277 277
     {
278 278
         return $this->rowCount;
279 279
     }
280 280
     
281
-   /**
282
-    * Counts the amount of rows in the parsed CSV, 
283
-    * excluding the headers if any, depending on
284
-    * their position.
285
-    * 
286
-    * @return integer
287
-    */
281
+    /**
282
+     * Counts the amount of rows in the parsed CSV, 
283
+     * excluding the headers if any, depending on
284
+     * their position.
285
+     * 
286
+     * @return integer
287
+     */
288 288
     public function countColumns()
289 289
     {
290 290
         return $this->columnCount;
291 291
     }
292 292
     
293
-   /**
294
-    * Retrieves the headers, if any. Specify the position of the
295
-    * headers first to ensure this works correctly.
296
-    * 
297
-    * @return array Indexed array with header names.
298
-    */
293
+    /**
294
+     * Retrieves the headers, if any. Specify the position of the
295
+     * headers first to ensure this works correctly.
296
+     * 
297
+     * @return array Indexed array with header names.
298
+     */
299 299
     public function getHeaders()
300 300
     {
301 301
         return $this->headers;
302 302
     }
303 303
     
304
-   /**
305
-    * Retrieves the column at the specified index. If there
306
-    * is no column at the index, this returns an array
307
-    * populated with empty strings.
308
-    * 
309
-    * Tip: Use the {@link columnExists()} method to check
310
-    * whether a column exists.
311
-    * 
312
-    * @param integer $index
313
-    * @return string[]
314
-    * @see columnExists()
315
-    */
304
+    /**
305
+     * Retrieves the column at the specified index. If there
306
+     * is no column at the index, this returns an array
307
+     * populated with empty strings.
308
+     * 
309
+     * Tip: Use the {@link columnExists()} method to check
310
+     * whether a column exists.
311
+     * 
312
+     * @param integer $index
313
+     * @return string[]
314
+     * @see columnExists()
315
+     */
316 316
     public function getColumn($index)
317 317
     {
318 318
         $data = array();
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
         return $data;
329 329
     }
330 330
     
331
-   /**
332
-    * Checks whether the specified column exists in the data set.
333
-    * @param integer $index
334
-    * @return boolean
335
-    */
331
+    /**
332
+     * Checks whether the specified column exists in the data set.
333
+     * @param integer $index
334
+     * @return boolean
335
+     */
336 336
     public function columnExists($index)
337 337
     {
338 338
         if($index < $this->columnCount) {
@@ -396,22 +396,22 @@  discard block
 block discarded – undo
396 396
         }
397 397
     }
398 398
     
399
-   /**
400
-    * Checks whether any errors have been encountered
401
-    * while parsing the CSV.
402
-    * 
403
-    * @return boolean
404
-    * @see getErrorMessages()
405
-    */
399
+    /**
400
+     * Checks whether any errors have been encountered
401
+     * while parsing the CSV.
402
+     * 
403
+     * @return boolean
404
+     * @see getErrorMessages()
405
+     */
406 406
     public function hasErrors()
407 407
     {
408 408
         return !empty($this->errors);
409 409
     }
410 410
     
411
-   /**
412
-    * Retrieves all error messages.
413
-    * @return array
414
-    */
411
+    /**
412
+     * Retrieves all error messages.
413
+     * @return array
414
+     */
415 415
     public function getErrorMessages()
416 416
     {
417 417
         return $this->errors;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     
171 171
     public function isHeadersPosition($position)
172 172
     {
173
-        if($this->headersPosition === $position) {
173
+        if ($this->headersPosition === $position) {
174 174
             return true;
175 175
         }
176 176
         
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             self::HEADERS_TOP
198 198
         );
199 199
         
200
-        if(!in_array($position, $validPositions)) {
200
+        if (!in_array($position, $validPositions)) {
201 201
             throw new CSVHelper_Exception(
202 202
                 'Invalid headers position',
203 203
                 sprintf(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     */
254 254
     public function getRow($index)
255 255
     {
256
-        if(isset($this->data[$index])) {
256
+        if (isset($this->data[$index])) {
257 257
             return $this->data[$index];
258 258
         }
259 259
         
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
     public function getColumn($index)
321 321
     {
322 322
         $data = array();
323
-        for($i=0; $i < $this->rowCount; $i++) {
323
+        for ($i = 0; $i < $this->rowCount; $i++) {
324 324
             $value = '';
325
-            if(isset($this->data[$i][$index])) {
325
+            if (isset($this->data[$i][$index])) {
326 326
                 $value = $this->data[$i][$index];
327 327
             }
328 328
             
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     */
340 340
     public function columnExists($index)
341 341
     {
342
-        if($index < $this->columnCount) {
342
+        if ($index < $this->columnCount) {
343 343
             return true;
344 344
         }
345 345
         
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     {
351 351
         $this->reset();
352 352
         
353
-        if(empty(trim($this->csv))) {
353
+        if (empty(trim($this->csv))) {
354 354
             $this->addError('Tried to parse an empty CSV string.');
355 355
             return;
356 356
         }
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
         
363 363
         $parser = self::createParser();
364 364
 
365
-        if(!$parser->parse($this->csv)) {
365
+        if (!$parser->parse($this->csv)) {
366 366
             $this->addError('The CSV string could not be parsed.');
367 367
             return;
368 368
         }
369 369
 
370 370
         $result = $parser->data;
371 371
 
372
-        switch($this->headersPosition)
372
+        switch ($this->headersPosition)
373 373
         {
374 374
             case self::HEADERS_TOP:
375 375
                 $this->headers = array_shift($result);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             case self::HEADERS_LEFT:
379 379
                 $keep = array();
380 380
                 $total = count($result);
381
-                for($i=0; $i < $total; $i++) {
381
+                for ($i = 0; $i < $total; $i++) {
382 382
                     $row = $result[$i];
383 383
                     $this->headers[] = array_shift($row);
384 384
                     $keep[] = $row;
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
         $this->data = $result;
392 392
         $this->rowCount = count($this->data);
393 393
         
394
-        for($i=0; $i < $this->rowCount; $i++) {
394
+        for ($i = 0; $i < $this->rowCount; $i++) {
395 395
             $amount = count($this->data[$i]);
396
-            if($amount > $this->columnCount) {
396
+            if ($amount > $this->columnCount) {
397 397
                 $this->columnCount = $amount;
398 398
             }
399 399
         }
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
             ',,' => ','
438 438
         );
439 439
         
440
-        foreach($search as $char => $separator) {
441
-            if(strstr($this->csv, $char)) {
440
+        foreach ($search as $char => $separator) {
441
+            if (strstr($this->csv, $char)) {
442 442
                 return $separator;
443 443
             }
444 444
         }
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
      * @param string $delimiter
453 453
      * @return Csv
454 454
      */
455
-    public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv
455
+    public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv
456 456
     {
457 457
         $csv = new Csv();
458 458
 
459
-        if($delimiter !== self::DELIMITER_AUTO) {
459
+        if ($delimiter !== self::DELIMITER_AUTO) {
460 460
             $csv->delimiter = $delimiter;
461 461
         }
462 462
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         $parser = self::createParser();
483 483
         $result = $parser->parse($path);
484 484
 
485
-        if($result === true) {
485
+        if ($result === true) {
486 486
             return $parser->data;
487 487
         }
488 488
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         $parser = self::createParser();
513 513
         $result = $parser->parse($string);
514 514
 
515
-        if($result === true) {
515
+        if ($result === true) {
516 516
             return $parser->data;
517 517
         }
518 518
 
Please login to merge, or discard this patch.
src/ImageHelper.php 3 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -151,8 +151,7 @@  discard block
 block discarded – undo
151 151
             $this->sourceImage = $resource;
152 152
             $this->type = $type;
153 153
             $this->info = self::getImageSize($resource);
154
-        } 
155
-        else 
154
+        } else 
156 155
         {
157 156
             $this->file = $sourceFile;
158 157
             if (!file_exists($this->file)) {
@@ -561,8 +560,7 @@  discard block
 block discarded – undo
561 560
         if ($this->width <= $this->height) 
562 561
         {
563 562
             $this->resampleByWidth($width);
564
-        } 
565
-        else 
563
+        } else 
566 564
         {
567 565
             $this->resampleByHeight($height);
568 566
         }
@@ -1037,8 +1035,7 @@  discard block
 block discarded – undo
1037 1035
         {
1038 1036
             $bg2 = imagecolorallocatealpha($im2, $color['red'], $color['green'], $color['blue'], $color['alpha']);
1039 1037
             imagecolortransparent($im2, $bg2);
1040
-        }
1041
-        else
1038
+        } else
1042 1039
         {
1043 1040
             $bg2 = imagecolorallocate($im2, $color['red'], $color['green'], $color['blue']);
1044 1041
         }
@@ -1348,8 +1345,7 @@  discard block
 block discarded – undo
1348 1345
 	    if(method_exists(__CLASS__, $method)) 
1349 1346
 	    {
1350 1347
 	        $info = call_user_func(array(__CLASS__, $method), $pathOrResource);
1351
-	    } 
1352
-	    else 
1348
+	    } else 
1353 1349
 	    {
1354 1350
 	        $info = getimagesize($pathOrResource);
1355 1351
 	    }
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
      * @throws ImageHelper_Exception
135 135
      * @see ImageHelper::ERROR_GD_LIBRARY_NOT_INSTALLED
136 136
      */
137
-    public function __construct(?string $sourceFile=null, $resource=null, ?string $type=null)
137
+    public function __construct(?string $sourceFile = null, $resource = null, ?string $type = null)
138 138
     {
139 139
         // ensure that the GD library is installed
140
-        if(!function_exists('imagecreate')) 
140
+        if (!function_exists('imagecreate')) 
141 141
         {
142 142
             throw new ImageHelper_Exception(
143 143
                 'The PHP GD extension is not installed or not enabled.',
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             );
147 147
         }
148 148
         
149
-        if(is_resource($resource)) 
149
+        if (is_resource($resource)) 
150 150
         {
151 151
             $this->sourceImage = $resource;
152 152
             $this->type = $type;
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
             if (is_null($this->type)) {
171 171
                 throw new ImageHelper_Exception(
172 172
                     'Error opening image',
173
-                    'Not a valid supported image type for image ' . $this->file,
173
+                    'Not a valid supported image type for image '.$this->file,
174 174
                     self::ERROR_UNSUPPORTED_IMAGE_TYPE
175 175
                 );
176 176
             }
177 177
 
178 178
             $this->info = self::getImageSize($this->file);
179 179
 
180
-            if(!$this->isVector()) 
180
+            if (!$this->isVector()) 
181 181
             {
182
-                $method = 'imagecreatefrom' . $this->type;
182
+                $method = 'imagecreatefrom'.$this->type;
183 183
                 $this->sourceImage = $method($this->file);
184 184
                 if (!$this->sourceImage) {
185 185
                     throw new ImageHelper_Exception(
186 186
                         'Error creating new image',
187
-                        $method . ' failed',
187
+                        $method.' failed',
188 188
                         self::ERROR_FAILED_TO_CREATE_NEW_IMAGE
189 189
                     );
190 190
                 }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $this->width = $this->info->getWidth();
197 197
         $this->height = $this->info->getHeight();
198 198
 
199
-        if(!$this->isVector()) {
199
+        if (!$this->isVector()) {
200 200
             $this->setNewImage($this->duplicateImage($this->sourceImage));
201 201
         }
202 202
     }
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
     *
213 213
     * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT
214 214
     */
215
-    public static function createNew($width, $height, $type='png')
215
+    public static function createNew($width, $height, $type = 'png')
216 216
     {
217 217
         $img = imagecreatetruecolor($width, $height);
218
-        if($img !== false) {
218
+        if ($img !== false) {
219 219
             return self::createFromResource($img, 'png');
220 220
         }
221 221
         
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     * @param string $type The target image type, e.g. "jpeg", "png", etc.
239 239
     * @return ImageHelper
240 240
     */
241
-    public static function createFromResource($resource, ?string $type=null)
241
+    public static function createFromResource($resource, ?string $type = null)
242 242
     {
243 243
         self::requireResource($resource);
244 244
         
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     */
271 271
     public static function setConfig($name, $value)
272 272
     {
273
-        if(isset(self::$config[$name])) {
273
+        if (isset(self::$config[$name])) {
274 274
             self::$config[$name] = $value;
275 275
         }
276 276
     }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     * 
282 282
     * @param bool $enabled
283 283
     */
284
-    public static function setAutoMemoryAdjustment($enabled=true)
284
+    public static function setAutoMemoryAdjustment($enabled = true)
285 285
     {
286 286
         self::setConfig('auto-memory-adjustment', $enabled);
287 287
     }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
     public function enableAlpha()
317 317
     {
318
-        if(!$this->alpha) 
318
+        if (!$this->alpha) 
319 319
         {
320 320
             self::addAlphaSupport($this->newImage, false);
321 321
             $this->alpha = true;
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
      * @param number $percent
347 347
      * @return ImageHelper
348 348
      */
349
-    public function sharpen($percent=0)
349
+    public function sharpen($percent = 0)
350 350
     {
351
-        if($percent <= 0) {
351
+        if ($percent <= 0) {
352 352
             return $this;
353 353
         }
354 354
         
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
         return $this->convolute($factor);
358 358
     }
359 359
     
360
-    public function blur($percent=0)
360
+    public function blur($percent = 0)
361 361
     {
362
-        if($percent <= 0) {
362
+        if ($percent <= 0) {
363 363
             return $this;
364 364
         }
365 365
         
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
     {
373 373
         // get a value thats equal to 64 - abs( factor )
374 374
         // ( using min/max to limited the factor to 0 - 64 to not get out of range values )
375
-        $val1Adjustment = 64 - min( 64, max( 0, abs( $factor ) ) );
375
+        $val1Adjustment = 64 - min(64, max(0, abs($factor)));
376 376
         
377 377
         // the base factor for the "current" pixel depends on if we are blurring or sharpening.
378 378
         // If we are blurring use 1, if sharpening use 9.
379 379
         $val1Base = 9;
380
-        if( abs( $factor ) != $factor ) {
380
+        if (abs($factor) != $factor) {
381 381
             $val1Base = 1;
382 382
         }
383 383
         
@@ -390,24 +390,24 @@  discard block
 block discarded – undo
390 390
         
391 391
         // the value for the surrounding pixels is either positive or negative depending on if we are blurring or sharpening.
392 392
         $val2 = -1;
393
-        if( abs( $factor ) != $factor ) {
393
+        if (abs($factor) != $factor) {
394 394
             $val2 = 1;
395 395
         }
396 396
         
397 397
         // setup matrix ..
398 398
         $matrix = array(
399
-            array( $val2, $val2, $val2 ),
400
-            array( $val2, $val1, $val2 ),
401
-            array( $val2, $val2, $val2 )
399
+            array($val2, $val2, $val2),
400
+            array($val2, $val1, $val2),
401
+            array($val2, $val2, $val2)
402 402
         );
403 403
         
404 404
         // calculate the correct divisor
405 405
         // actual divisor is equal to "$divisor = $val1 + $val2 * 8;"
406 406
         // but the following line is more generic
407
-        $divisor = array_sum( array_map( 'array_sum', $matrix ) );
407
+        $divisor = array_sum(array_map('array_sum', $matrix));
408 408
         
409 409
         // apply the matrix
410
-        imageconvolution( $this->newImage, $matrix, $divisor, 0 );
410
+        imageconvolution($this->newImage, $matrix, $divisor, 0);
411 411
         
412 412
         return $this;
413 413
     }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
     */
534 534
     public function resample(?int $width = null, ?int $height = null) : ImageHelper
535 535
     {
536
-        if($this->isVector()) {
536
+        if ($this->isVector()) {
537 537
             return $this;
538 538
         }
539 539
         
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 
555 555
     public function resampleAndCrop($width, $height) : ImageHelper
556 556
     {
557
-        if($this->isVector()) {
557
+        if ($this->isVector()) {
558 558
             return $this;
559 559
         }
560 560
 
@@ -601,14 +601,14 @@  discard block
 block discarded – undo
601 601
     * @param resource $canvas
602 602
     * @param bool $fill Whether to fill the whole canvas with the transparency
603 603
     */
604
-    public static function addAlphaSupport($canvas, $fill=true)
604
+    public static function addAlphaSupport($canvas, $fill = true)
605 605
     {
606 606
         self::requireResource($canvas);
607 607
         
608
-        imagealphablending($canvas,true);
608
+        imagealphablending($canvas, true);
609 609
         imagesavealpha($canvas, true);
610 610
 
611
-        if($fill) {
611
+        if ($fill) {
612 612
             self::fillImageTransparent($canvas);
613 613
         }
614 614
     }
@@ -618,13 +618,13 @@  discard block
 block discarded – undo
618 618
         return $this->alpha;
619 619
     }
620 620
 
621
-    public function save(string $targetFile, $dispose=true)
621
+    public function save(string $targetFile, $dispose = true)
622 622
     {
623
-        if($this->isVector()) {
623
+        if ($this->isVector()) {
624 624
             return true;
625 625
         }
626 626
         
627
-        if(!is_resource($this->newImage)) {
627
+        if (!is_resource($this->newImage)) {
628 628
             throw new ImageHelper_Exception(
629 629
                 'Error creating new image',
630 630
                 'Cannot save an image, no valid image resource was created. You have to call one of the resample methods to create a new image.',
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
             unlink($targetFile);
637 637
         }
638 638
         
639
-        $method = 'image' . $this->type;
639
+        $method = 'image'.$this->type;
640 640
         if (!$method($this->newImage, $targetFile, $this->resolveQuality())) {
641 641
             throw new ImageHelper_Exception(
642 642
                 'Error creating new image',
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
             );
658 658
         }
659 659
 
660
-        if($dispose) {
660
+        if ($dispose) {
661 661
             $this->dispose();
662 662
         }
663 663
         
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
     
667 667
     public function dispose()
668 668
     {
669
-        if(is_resource($this->sourceImage)) {
669
+        if (is_resource($this->sourceImage)) {
670 670
             imagedestroy($this->sourceImage);
671 671
         }
672 672
         
673
-        if(is_resource($this->newImage)) {
673
+        if (is_resource($this->newImage)) {
674 674
             imagedestroy($this->newImage);
675 675
         }
676 676
     }
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     */
724 724
     protected function adjustMemory() : bool
725 725
     {
726
-        if(!self::$config['auto-memory-adjustment']) {
726
+        if (!self::$config['auto-memory-adjustment']) {
727 727
             return true;
728 728
         }
729 729
         
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         if (function_exists('memory_get_usage') && memory_get_usage() + $memoryNeeded > $memoryLimit) {
753 753
             $newLimit = ($memoryLimit + (memory_get_usage() + $memoryNeeded)) / $MB;
754 754
             $newLimit = ceil($newLimit);
755
-            ini_set('memory_limit', $newLimit . 'M');
755
+            ini_set('memory_limit', $newLimit.'M');
756 756
 
757 757
             return true;
758 758
         }
@@ -783,16 +783,16 @@  discard block
 block discarded – undo
783 783
     */
784 784
     protected function resampleImage(int $newWidth, int $newHeight) : ImageHelper
785 785
     {
786
-        if($this->isVector()) {
786
+        if ($this->isVector()) {
787 787
             return $this;
788 788
         }
789 789
 
790
-        if($this->newWidth==$newWidth && $this->newHeight==$newHeight) {
790
+        if ($this->newWidth == $newWidth && $this->newHeight == $newHeight) {
791 791
             return $this;
792 792
         }
793 793
         
794
-        if($newWidth < 1) { $newWidth = 1; }
795
-        if($newHeight < 1) { $newHeight = 1; }
794
+        if ($newWidth < 1) { $newWidth = 1; }
795
+        if ($newHeight < 1) { $newHeight = 1; }
796 796
         
797 797
         $this->adjustMemory();
798 798
 
@@ -860,15 +860,15 @@  discard block
 block discarded – undo
860 860
     * @see ImageHelper::ERROR_NOT_A_RESOURCE
861 861
     * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE
862 862
     */
863
-    public static function displayImageStream($resource, string $imageType, int $quality=-1) : void
863
+    public static function displayImageStream($resource, string $imageType, int $quality = -1) : void
864 864
     {
865 865
         self::requireResource($resource);
866 866
 
867 867
         $imageType = self::requireValidStreamType($imageType);
868 868
         
869
-        header('Content-type:image/' . $imageType);
869
+        header('Content-type:image/'.$imageType);
870 870
 
871
-        $function = 'image' . $imageType;
871
+        $function = 'image'.$imageType;
872 872
         
873 873
         $function($resource, null, $quality);
874 874
     }
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
     {
886 886
         $imageType = strtolower($imageType);
887 887
 
888
-        if(in_array($imageType, self::$streamTypes))
888
+        if (in_array($imageType, self::$streamTypes))
889 889
         {
890 890
             return $imageType;
891 891
         }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
         if (headers_sent($file, $line)) {
912 912
             throw new ImageHelper_Exception(
913 913
                 'Error displaying image',
914
-                'Headers have already been sent: in file ' . $file . ':' . $line,
914
+                'Headers have already been sent: in file '.$file.':'.$line,
915 915
                 self::ERROR_HEADERS_ALREADY_SENT
916 916
             );
917 917
         }
@@ -928,16 +928,16 @@  discard block
 block discarded – undo
928 928
         }
929 929
 
930 930
         $format = self::getFileImageType($imageFile);
931
-        if($format == 'svg') {
931
+        if ($format == 'svg') {
932 932
             $format = 'svg+xml';
933 933
         }
934 934
 
935
-        $contentType = 'image/' . $format;
935
+        $contentType = 'image/'.$format;
936 936
         
937 937
         header('Content-Type: '.$contentType);
938
-        header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($imageFile)) . " GMT");
938
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($imageFile))." GMT");
939 939
         header('Cache-Control: public');
940
-        header('Content-Length: ' . filesize($imageFile));
940
+        header('Content-Length: '.filesize($imageFile));
941 941
 
942 942
         readfile($imageFile);
943 943
     }
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
      * @see ImageHelper::ERROR_NOT_A_RESOURCE
966 966
      * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_CANVAS
967 967
      */
968
-    public function trim(?array $color=null) : ImageHelper
968
+    public function trim(?array $color = null) : ImageHelper
969 969
     {
970 970
         return $this->trimImage($this->newImage, $color);
971 971
     }
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
         $color = imagecolorsforindex($img, $colorIndex);
988 988
         
989 989
         // it seems imagecolorsforindex may return false (undocumented, unproven)
990
-        if(is_array($color)) {
990
+        if (is_array($color)) {
991 991
             return $color;
992 992
         }
993 993
         
@@ -1011,15 +1011,15 @@  discard block
 block discarded – undo
1011 1011
     * @see ImageHelper::ERROR_NOT_A_RESOURCE
1012 1012
     * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_CANVAS
1013 1013
     */
1014
-    protected function trimImage($img, ?array $color=null) : ImageHelper
1014
+    protected function trimImage($img, ?array $color = null) : ImageHelper
1015 1015
     {
1016
-        if($this->isVector()) {
1016
+        if ($this->isVector()) {
1017 1017
             return $this;
1018 1018
         }
1019 1019
 
1020 1020
         self::requireResource($img);
1021 1021
         
1022
-        if(empty($color)) 
1022
+        if (empty($color)) 
1023 1023
         {
1024 1024
             $color = imagecolorat($img, 0, 0);
1025 1025
             $color = $this->getIndexedColors($img, $color);
@@ -1036,16 +1036,16 @@  discard block
 block discarded – undo
1036 1036
         $ymax = null;
1037 1037
          
1038 1038
         // Start scanning for the edges.
1039
-        for ($iy=0; $iy<$imh; $iy++)
1039
+        for ($iy = 0; $iy < $imh; $iy++)
1040 1040
         {
1041 1041
             $first = true;
1042 1042
             
1043
-            for ($ix=0; $ix<$imw; $ix++)
1043
+            for ($ix = 0; $ix < $imw; $ix++)
1044 1044
             {
1045 1045
                 $ndx = imagecolorat($img, $ix, $iy);
1046 1046
                 $colors = $this->getIndexedColors($img, $ndx);
1047 1047
                 
1048
-                if(!$this->colorsMatch($colors, $color)) 
1048
+                if (!$this->colorsMatch($colors, $color)) 
1049 1049
                 {
1050 1050
                     if ($xmin > $ix) { $xmin = $ix; }
1051 1051
                     if ($xmax < $ix) { $xmax = $ix; }
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
                     
1054 1054
                     $ymax = $iy;
1055 1055
                     
1056
-                    if($first)
1056
+                    if ($first)
1057 1057
                     { 
1058 1058
                         $ix = $xmax; 
1059 1059
                         $first = false; 
@@ -1063,18 +1063,18 @@  discard block
 block discarded – undo
1063 1063
         }
1064 1064
         
1065 1065
         // no trimming border found
1066
-        if($ymax === null) {
1066
+        if ($ymax === null) {
1067 1067
             return $this;
1068 1068
         }
1069 1069
         
1070 1070
         // The new width and height of the image. 
1071
-        $imw = 1+$xmax-$xmin; // Image width in pixels
1072
-        $imh = 1+$ymax-$ymin; // Image height in pixels
1071
+        $imw = 1 + $xmax - $xmin; // Image width in pixels
1072
+        $imh = 1 + $ymax - $ymin; // Image height in pixels
1073 1073
 
1074 1074
         // Make another image to place the trimmed version in.
1075 1075
         $im2 = $this->createNewImage($imw, $imh);
1076 1076
         
1077
-        if($color['alpha'] > 0) 
1077
+        if ($color['alpha'] > 0) 
1078 1078
         {
1079 1079
             $bg2 = imagecolorallocatealpha($im2, $color['red'], $color['green'], $color['blue'], $color['alpha']);
1080 1080
             imagecolortransparent($im2, $bg2);
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
         
1114 1114
         $this->newImage = $image;
1115 1115
         $this->newWidth = imagesx($image);
1116
-        $this->newHeight= imagesy($image);
1116
+        $this->newHeight = imagesy($image);
1117 1117
 
1118 1118
         return $this;
1119 1119
     }
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
     */
1129 1129
     protected static function requireResource($subject) : void
1130 1130
     {
1131
-        if(is_resource($subject)) {
1131
+        if (is_resource($subject)) {
1132 1132
             return;
1133 1133
         }
1134 1134
         
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
     {
1155 1155
         $img = imagecreatetruecolor($width, $height);
1156 1156
         
1157
-        if($img === false) 
1157
+        if ($img === false) 
1158 1158
         {
1159 1159
             throw new ImageHelper_Exception(
1160 1160
                 'Error creating new image',
@@ -1178,8 +1178,8 @@  discard block
 block discarded – undo
1178 1178
 	protected function colorsMatch(array $a, array $b) : bool
1179 1179
 	{
1180 1180
 		$parts = array('red', 'green', 'blue');
1181
-		foreach($parts as $part) {
1182
-			if($a[$part] != $b[$part]) {
1181
+		foreach ($parts as $part) {
1182
+			if ($a[$part] != $b[$part]) {
1183 1183
 				return false;
1184 1184
 			}
1185 1185
 		} 
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 		return true;
1188 1188
 	}
1189 1189
 	
1190
-	public function fillWhite($x=0, $y=0)
1190
+	public function fillWhite($x = 0, $y = 0)
1191 1191
 	{
1192 1192
 	    $this->addRGBColor('white', 255, 255, 255);
1193 1193
         return $this->fill('white', $x, $y);
@@ -1207,11 +1207,11 @@  discard block
 block discarded – undo
1207 1207
 	    self::requireResource($resource);
1208 1208
 	    
1209 1209
 	    $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127);
1210
-	    imagecolortransparent ($resource, $transparent);
1210
+	    imagecolortransparent($resource, $transparent);
1211 1211
 	    imagefill($resource, 0, 0, $transparent);
1212 1212
 	}
1213 1213
 	
1214
-	public function fill($colorName, $x=0, $y=0)
1214
+	public function fill($colorName, $x = 0, $y = 0)
1215 1215
 	{
1216 1216
 	    imagefill($this->newImage, $x, $y, $this->colors[$colorName]);
1217 1217
 	    return $this;
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
         return $this;
1226 1226
     }
1227 1227
     
1228
-    public function textTTF($text, $size, $colorName, $x=0, $y=0, $angle=0)
1228
+    public function textTTF($text, $size, $colorName, $x = 0, $y = 0, $angle = 0)
1229 1229
     {
1230 1230
         imagealphablending($this->newImage, true);
1231 1231
         
@@ -1244,11 +1244,11 @@  discard block
 block discarded – undo
1244 1244
         return $this->newImage;
1245 1245
     }
1246 1246
     
1247
-    public function paste(ImageHelper $target, $xpos=0, $ypos=0, $sourceX=0, $sourceY=0)
1247
+    public function paste(ImageHelper $target, $xpos = 0, $ypos = 0, $sourceX = 0, $sourceY = 0)
1248 1248
     {
1249 1249
         $img = $target->getImage();
1250 1250
         
1251
-        if($target->isAlpha()) {
1251
+        if ($target->isAlpha()) {
1252 1252
             $this->enableAlpha();
1253 1253
         }
1254 1254
         
@@ -1293,10 +1293,10 @@  discard block
 block discarded – undo
1293 1293
     public function fitText($text, $matchWidth)
1294 1294
     {
1295 1295
         $sizes = array();
1296
-        for($i=1; $i<=1000; $i=$i+0.1) {
1296
+        for ($i = 1; $i <= 1000; $i = $i + 0.1) {
1297 1297
             $size = $this->calcTextSize($text, $i);
1298 1298
             $sizes[] = $size;
1299
-            if($size['width'] >= $matchWidth) {
1299
+            if ($size['width'] >= $matchWidth) {
1300 1300
                 break;
1301 1301
             }
1302 1302
         }
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
         $diffLast = $last['width'] - $matchWidth;
1309 1309
         $diffPrev = $matchWidth - $prev['width'];
1310 1310
     
1311
-        if($diffLast <= $diffPrev) {
1311
+        if ($diffLast <= $diffPrev) {
1312 1312
             return $last;
1313 1313
         }
1314 1314
     
@@ -1336,14 +1336,14 @@  discard block
 block discarded – undo
1336 1336
             'bottom_left_y' => $box[1],
1337 1337
             'bottom_right_x' => $box[2],
1338 1338
             'bottom_right_y' => $box[3],
1339
-            'width' => $right-$left,
1340
-            'height' => $bottom-$top
1339
+            'width' => $right - $left,
1340
+            'height' => $bottom - $top
1341 1341
         );
1342 1342
     }
1343 1343
     
1344 1344
     protected function requireTTFFont()
1345 1345
     {
1346
-        if(isset($this->TTFFile)) {
1346
+        if (isset($this->TTFFile)) {
1347 1347
             return;
1348 1348
         }
1349 1349
         
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 	 */
1379 1379
 	public static function getImageSize($pathOrResource) : ImageHelper_Size
1380 1380
 	{
1381
-	    if(is_resource($pathOrResource)) 
1381
+	    if (is_resource($pathOrResource)) 
1382 1382
 	    {
1383 1383
 	        return new ImageHelper_Size(array(
1384 1384
 	            'width' => imagesx($pathOrResource),
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 	    
1393 1393
 	    $info = false;
1394 1394
 	    $method = 'getImageSize_'.$type;
1395
-	    if(method_exists(__CLASS__, $method)) 
1395
+	    if (method_exists(__CLASS__, $method)) 
1396 1396
 	    {
1397 1397
 	        $info = call_user_func(array(__CLASS__, $method), $pathOrResource);
1398 1398
 	    } 
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 	        $info = getimagesize($pathOrResource);
1402 1402
 	    }
1403 1403
 	    
1404
-	    if($info !== false) {
1404
+	    if ($info !== false) {
1405 1405
 	        return new ImageHelper_Size($info);
1406 1406
 	    }
1407 1407
 	    
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 	    $xml = XMLHelper::createSimplexml();
1428 1428
 	    $xml->loadFile($imagePath);
1429 1429
 	    
1430
-	    if($xml->hasErrors()) {
1430
+	    if ($xml->hasErrors()) {
1431 1431
 	        throw new ImageHelper_Exception(
1432 1432
 	            'Error opening SVG image',
1433 1433
 	            sprintf(
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 	    $xml->dispose();
1443 1443
 	    unset($xml);
1444 1444
 	    
1445
-	    if(!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) {
1445
+	    if (!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) {
1446 1446
 	        throw new ImageHelper_Exception(
1447 1447
 	            'SVG Image is corrupted',
1448 1448
 	            sprintf(
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 	    $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']);
1460 1460
 	    $size = explode(',', $viewBox);
1461 1461
 	    
1462
-	    if(count($size) != 4) 
1462
+	    if (count($size) != 4) 
1463 1463
 	    {
1464 1464
 	        throw new ImageHelper_Exception(
1465 1465
 	            'SVG image has an invalid viewBox attribute',
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
     * @param integer $y
1506 1506
     * @return ImageHelper
1507 1507
     */
1508
-    public function crop(int $width, int $height, int $x=0, int $y=0) : ImageHelper
1508
+    public function crop(int $width, int $height, int $x = 0, int $y = 0) : ImageHelper
1509 1509
     {
1510 1510
         $new = $this->createNewImage($width, $height);
1511 1511
         
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
     * @see ImageHelper::calcAverageColorRGB()
1543 1543
     * @see ImageHelper::calcAverageColorHEX()
1544 1544
     */
1545
-    public function calcAverageColor(int $format=self::COLORFORMAT_RGB)
1545
+    public function calcAverageColor(int $format = self::COLORFORMAT_RGB)
1546 1546
     {
1547 1547
         $image = $this->duplicate();
1548 1548
         $image->resample(1, 1);
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
     public function calcAverageColorRGB() : array
1562 1562
     {
1563 1563
        $result = $this->calcAverageColor(self::COLORFORMAT_RGB);
1564
-       if(is_array($result)) {
1564
+       if (is_array($result)) {
1565 1565
            return $result;
1566 1566
        }
1567 1567
        
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
     public function calcAverageColorHex() : string
1583 1583
     {
1584 1584
         $result = $this->calcAverageColor(self::COLORFORMAT_HEX);
1585
-        if(is_string($result)) {
1585
+        if (is_string($result)) {
1586 1586
             return $result;
1587 1587
         }
1588 1588
         
@@ -1618,9 +1618,9 @@  discard block
 block discarded – undo
1618 1618
      * @throws ImageHelper_Exception
1619 1619
      * @see ImageHelper::ERROR_POSITION_OUT_OF_BOUNDS
1620 1620
      */
1621
-    public function getColorAt(int $x, int $y, int $format=self::COLORFORMAT_RGB)
1621
+    public function getColorAt(int $x, int $y, int $format = self::COLORFORMAT_RGB)
1622 1622
     {
1623
-        if($x > $this->getWidth() || $y > $this->getHeight()) 
1623
+        if ($x > $this->getWidth() || $y > $this->getHeight()) 
1624 1624
         {
1625 1625
             throw new ImageHelper_Exception(
1626 1626
                 'Position out of bounds',
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
         $idx = imagecolorat($this->newImage, $x, $y);
1639 1639
         $rgb = $this->getIndexedColors($this->newImage, $idx);
1640 1640
         
1641
-        if($format == self::COLORFORMAT_HEX) {
1641
+        if ($format == self::COLORFORMAT_HEX) {
1642 1642
             return self::rgb2hex($rgb);
1643 1643
         }
1644 1644
 
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
     */
1654 1654
     public static function rgb2luma(array $rgb) : int
1655 1655
     {
1656
-        return (int)floor((($rgb['red']*2)+$rgb['blue']+($rgb['green']*3))/6);
1656
+        return (int)floor((($rgb['red'] * 2) + $rgb['blue'] + ($rgb['green'] * 3)) / 6);
1657 1657
     }
1658 1658
 
1659 1659
     /**
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
     */
1682 1682
     public function getHash() : string
1683 1683
     {
1684
-        if($this->newImage === null)
1684
+        if ($this->newImage === null)
1685 1685
         {
1686 1686
             throw new ImageHelper_Exception(
1687 1687
                 'No image loaded to create a hash for.',
Please login to merge, or discard this patch.
Indentation   +420 added lines, -420 removed lines patch added patch discarded remove patch
@@ -50,53 +50,53 @@  discard block
 block discarded – undo
50 50
     public const COLORFORMAT_HEX = 2;
51 51
 
52 52
     /**
53
-    * @var string
54
-    */
53
+     * @var string
54
+     */
55 55
     protected $file;
56 56
 
57
-   /**
58
-    * @var ImageHelper_Size
59
-    */
57
+    /**
58
+     * @var ImageHelper_Size
59
+     */
60 60
     protected $info;
61 61
 
62
-   /**
63
-    * @var string
64
-    */
62
+    /**
63
+     * @var string
64
+     */
65 65
     protected $type;
66 66
 
67
-   /**
68
-    * @var resource|NULL
69
-    */
67
+    /**
68
+     * @var resource|NULL
69
+     */
70 70
     protected $newImage;
71 71
 
72
-   /**
73
-    * @var resource
74
-    */
72
+    /**
73
+     * @var resource
74
+     */
75 75
     protected $sourceImage;
76 76
 
77
-   /**
78
-    * @var int
79
-    */
77
+    /**
78
+     * @var int
79
+     */
80 80
     protected $width;
81 81
 
82
-   /**
83
-    * @var int
84
-    */
82
+    /**
83
+     * @var int
84
+     */
85 85
     protected $height;
86 86
 
87
-   /**
88
-    * @var int
89
-    */
87
+    /**
88
+     * @var int
89
+     */
90 90
     protected $newWidth = 0;
91 91
 
92
-   /**
93
-    * @var int
94
-    */
92
+    /**
93
+     * @var int
94
+     */
95 95
     protected $newHeight = 0;
96 96
 
97
-   /**
98
-    * @var int
99
-    */
97
+    /**
98
+     * @var int
99
+     */
100 100
     protected $quality = 85;
101 101
 
102 102
     /**
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
         }
202 202
     }
203 203
 
204
-   /**
205
-    * Factory method: creates a new helper with a blank image.
206
-    * 
207
-    * @param integer $width
208
-    * @param integer $height
209
-    * @param string $type The target file type when saving
210
-    * @return ImageHelper
211
-    * @throws ImageHelper_Exception
212
-    *
213
-    * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT
214
-    */
204
+    /**
205
+     * Factory method: creates a new helper with a blank image.
206
+     * 
207
+     * @param integer $width
208
+     * @param integer $height
209
+     * @param string $type The target file type when saving
210
+     * @return ImageHelper
211
+     * @throws ImageHelper_Exception
212
+     *
213
+     * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_OBJECT
214
+     */
215 215
     public static function createNew($width, $height, $type='png')
216 216
     {
217 217
         $img = imagecreatetruecolor($width, $height);
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
         );
227 227
     }
228 228
     
229
-   /**
230
-    * Factory method: creates an image helper from an
231
-    * existing image resource.
232
-    *
233
-    * Note: while the resource is type independent, the
234
-    * type parameter is required for some methods, as well
235
-    * as to be able to save the image.
236
-    *
237
-    * @param resource $resource
238
-    * @param string $type The target image type, e.g. "jpeg", "png", etc.
239
-    * @return ImageHelper
240
-    */
229
+    /**
230
+     * Factory method: creates an image helper from an
231
+     * existing image resource.
232
+     *
233
+     * Note: while the resource is type independent, the
234
+     * type parameter is required for some methods, as well
235
+     * as to be able to save the image.
236
+     *
237
+     * @param resource $resource
238
+     * @param string $type The target image type, e.g. "jpeg", "png", etc.
239
+     * @return ImageHelper
240
+     */
241 241
     public static function createFromResource($resource, ?string $type=null)
242 242
     {
243 243
         self::requireResource($resource);
@@ -245,29 +245,29 @@  discard block
 block discarded – undo
245 245
         return new ImageHelper(null, $resource, $type);
246 246
     }
247 247
     
248
-   /**
249
-    * Factory method: creates an image helper from an
250
-    * image file on disk.
251
-    *
252
-    * @param string $file
253
-    * @return ImageHelper
254
-    */
248
+    /**
249
+     * Factory method: creates an image helper from an
250
+     * image file on disk.
251
+     *
252
+     * @param string $file
253
+     * @return ImageHelper
254
+     */
255 255
     public static function createFromFile(string $file) : ImageHelper
256 256
     {
257 257
         return new ImageHelper($file);
258 258
     }
259 259
     
260
-   /**
261
-    * Sets a global image helper configuration value. Available
262
-    * configuration settings are:
263
-    * 
264
-    * <ul>
265
-    * <li><code>auto-memory-adjustment</code> <i>boolean</i> Whether totry and adjust the memory limit automatically so there will be enough to load/process the target image.</li>
266
-    * </ul>
267
-    * 
268
-    * @param string $name
269
-    * @param mixed $value
270
-    */
260
+    /**
261
+     * Sets a global image helper configuration value. Available
262
+     * configuration settings are:
263
+     * 
264
+     * <ul>
265
+     * <li><code>auto-memory-adjustment</code> <i>boolean</i> Whether totry and adjust the memory limit automatically so there will be enough to load/process the target image.</li>
266
+     * </ul>
267
+     * 
268
+     * @param string $name
269
+     * @param mixed $value
270
+     */
271 271
     public static function setConfig($name, $value)
272 272
     {
273 273
         if(isset(self::$config[$name])) {
@@ -275,22 +275,22 @@  discard block
 block discarded – undo
275 275
         }
276 276
     }
277 277
     
278
-   /**
279
-    * Shorthand for setting the automatic memory adjustment
280
-    * global configuration setting.
281
-    * 
282
-    * @param bool $enabled
283
-    */
278
+    /**
279
+     * Shorthand for setting the automatic memory adjustment
280
+     * global configuration setting.
281
+     * 
282
+     * @param bool $enabled
283
+     */
284 284
     public static function setAutoMemoryAdjustment($enabled=true)
285 285
     {
286 286
         self::setConfig('auto-memory-adjustment', $enabled);
287 287
     }
288 288
     
289
-   /**
290
-    * Duplicates an image resource.
291
-    * @param resource $img
292
-    * @return resource
293
-    */
289
+    /**
290
+     * Duplicates an image resource.
291
+     * @param resource $img
292
+     * @return resource
293
+     */
294 294
     protected function duplicateImage($img)
295 295
     {
296 296
         self::requireResource($img);
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
         return $duplicate;
303 303
     }
304 304
     
305
-   /**
306
-    * Duplicates the current state of the image into a new
307
-    * image helper instance.
308
-    * 
309
-    * @return ImageHelper
310
-    */
305
+    /**
306
+     * Duplicates the current state of the image into a new
307
+     * image helper instance.
308
+     * 
309
+     * @return ImageHelper
310
+     */
311 311
     public function duplicate()
312 312
     {
313 313
         return ImageHelper::createFromResource($this->duplicateImage($this->newImage));
@@ -495,13 +495,13 @@  discard block
 block discarded – undo
495 495
         ));
496 496
     }
497 497
     
498
-   /**
499
-    * Resamples the image to a new width, maintaining
500
-    * aspect ratio.
501
-    * 
502
-    * @param int $width
503
-    * @return ImageHelper
504
-    */
498
+    /**
499
+     * Resamples the image to a new width, maintaining
500
+     * aspect ratio.
501
+     * 
502
+     * @param int $width
503
+     * @return ImageHelper
504
+     */
505 505
     public function resampleByWidth(int $width) : ImageHelper
506 506
     {
507 507
         $size = $this->getSizeByWidth($width);
@@ -511,12 +511,12 @@  discard block
 block discarded – undo
511 511
         return $this;
512 512
     }
513 513
 
514
-   /**
515
-    * Resamples the image by height, and creates a new image file on disk.
516
-    * 
517
-    * @param int $height
518
-    * @return ImageHelper
519
-    */
514
+    /**
515
+     * Resamples the image by height, and creates a new image file on disk.
516
+     * 
517
+     * @param int $height
518
+     * @return ImageHelper
519
+     */
520 520
     public function resampleByHeight($height) : ImageHelper
521 521
     {
522 522
         $size = $this->getSizeByHeight($height);
@@ -524,13 +524,13 @@  discard block
 block discarded – undo
524 524
         return $this->resampleImage($size->getWidth(), $size->getHeight());
525 525
     }
526 526
 
527
-   /**
528
-    * Resamples the image without keeping the aspect ratio.
529
-    * 
530
-    * @param int $width
531
-    * @param int $height
532
-    * @return ImageHelper
533
-    */
527
+    /**
528
+     * Resamples the image without keeping the aspect ratio.
529
+     * 
530
+     * @param int $width
531
+     * @param int $height
532
+     * @return ImageHelper
533
+     */
534 534
     public function resample(?int $width = null, ?int $height = null) : ImageHelper
535 535
     {
536 536
         if($this->isVector()) {
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
     
596 596
     protected $alpha = false;
597 597
 
598
-   /**
599
-    * Configures the specified image resource to make it alpha compatible.
600
-    * 
601
-    * @param resource $canvas
602
-    * @param bool $fill Whether to fill the whole canvas with the transparency
603
-    */
598
+    /**
599
+     * Configures the specified image resource to make it alpha compatible.
600
+     * 
601
+     * @param resource $canvas
602
+     * @param bool $fill Whether to fill the whole canvas with the transparency
603
+     */
604 604
     public static function addAlphaSupport($canvas, $fill=true)
605 605
     {
606 606
         self::requireResource($canvas);
@@ -715,12 +715,12 @@  discard block
 block discarded – undo
715 715
         $this->quality = $quality * 1;
716 716
     }
717 717
 
718
-   /**
719
-    * Attempts to adjust the memory to the required size
720
-    * to work with the current image.
721
-    * 
722
-    * @return boolean
723
-    */
718
+    /**
719
+     * Attempts to adjust the memory to the required size
720
+     * to work with the current image.
721
+     * 
722
+     * @return boolean
723
+     */
724 724
     protected function adjustMemory() : bool
725 725
     {
726 726
         if(!self::$config['auto-memory-adjustment']) {
@@ -760,27 +760,27 @@  discard block
 block discarded – undo
760 760
         return false;
761 761
     }
762 762
 
763
-   /**
764
-    * Stretches the image to the specified dimensions.
765
-    * 
766
-    * @param int $width
767
-    * @param int $height
768
-    * @return ImageHelper
769
-    */
763
+    /**
764
+     * Stretches the image to the specified dimensions.
765
+     * 
766
+     * @param int $width
767
+     * @param int $height
768
+     * @return ImageHelper
769
+     */
770 770
     public function stretch(int $width, int $height) : ImageHelper
771 771
     {
772 772
         return $this->resampleImage($width, $height);
773 773
     }
774 774
 
775
-   /**
776
-    * Creates a new image from the current image,
777
-    * resampling it to the new size.
778
-    * 
779
-    * @param int $newWidth
780
-    * @param int $newHeight   
781
-    * @throws ImageHelper_Exception
782
-    * @return ImageHelper
783
-    */
775
+    /**
776
+     * Creates a new image from the current image,
777
+     * resampling it to the new size.
778
+     * 
779
+     * @param int $newWidth
780
+     * @param int $newHeight   
781
+     * @throws ImageHelper_Exception
782
+     * @return ImageHelper
783
+     */
784 784
     protected function resampleImage(int $newWidth, int $newHeight) : ImageHelper
785 785
     {
786 786
         if($this->isVector()) {
@@ -849,17 +849,17 @@  discard block
 block discarded – undo
849 849
         return array_unique($types);
850 850
     }
851 851
     
852
-   /**
853
-    * Displays an existing image resource.
854
-    *
855
-    * @param resource $resource
856
-    * @param string $imageType The image format to send, i.e. "jpeg", "png"
857
-    * @param int $quality The quality to use for the image. This is 0-9 (0=no compression, 9=max) for PNG, and 0-100 (0=lowest, 100=highest quality) for JPG
858
-    *
859
-    * @throws ImageHelper_Exception
860
-    * @see ImageHelper::ERROR_NOT_A_RESOURCE
861
-    * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE
862
-    */
852
+    /**
853
+     * Displays an existing image resource.
854
+     *
855
+     * @param resource $resource
856
+     * @param string $imageType The image format to send, i.e. "jpeg", "png"
857
+     * @param int $quality The quality to use for the image. This is 0-9 (0=no compression, 9=max) for PNG, and 0-100 (0=lowest, 100=highest quality) for JPG
858
+     *
859
+     * @throws ImageHelper_Exception
860
+     * @see ImageHelper::ERROR_NOT_A_RESOURCE
861
+     * @see ImageHelper::ERROR_INVALID_STREAM_IMAGE_TYPE
862
+     */
863 863
     public static function displayImageStream($resource, string $imageType, int $quality=-1) : void
864 864
     {
865 865
         self::requireResource($resource);
@@ -942,11 +942,11 @@  discard block
 block discarded – undo
942 942
         readfile($imageFile);
943 943
     }
944 944
     
945
-   /**
946
-    * Displays the current image.
947
-    *
948
-    * NOTE: You must call `exit()` manually after this.
949
-    */
945
+    /**
946
+     * Displays the current image.
947
+     *
948
+     * NOTE: You must call `exit()` manually after this.
949
+     */
950 950
     public function display() : void
951 951
     {
952 952
         $this->displayImageStream(
@@ -970,16 +970,16 @@  discard block
 block discarded – undo
970 970
         return $this->trimImage($this->newImage, $color);
971 971
     }
972 972
     
973
-   /**
974
-    * Retrieves a color definition by its index.
975
-    * 
976
-    * @param resource $img A valid image resource.
977
-    * @param int $colorIndex The color index, as returned by `imagecolorat` for example.
978
-    * @return array<string,int> An array with red, green, blue and alpha keys.
979
-    *
980
-    * @throws ImageHelper_Exception
981
-    * @see ImageHelper::ERROR_NOT_A_RESOURCE
982
-    */
973
+    /**
974
+     * Retrieves a color definition by its index.
975
+     * 
976
+     * @param resource $img A valid image resource.
977
+     * @param int $colorIndex The color index, as returned by `imagecolorat` for example.
978
+     * @return array<string,int> An array with red, green, blue and alpha keys.
979
+     *
980
+     * @throws ImageHelper_Exception
981
+     * @see ImageHelper::ERROR_NOT_A_RESOURCE
982
+     */
983 983
     public function getIndexedColors($img, int $colorIndex) : array
984 984
     {
985 985
         self::requireResource($img);
@@ -999,18 +999,18 @@  discard block
 block discarded – undo
999 999
         );
1000 1000
     }
1001 1001
         
1002
-   /**
1003
-    * Trims the specified image resource by removing the specified color.
1004
-    * Also works with transparency.
1005
-    * 
1006
-    * @param resource $img
1007
-    * @param array|NULL $color A color definition, as an associative array with red, green, blue and alpha keys. If not specified, the color at pixel position 0,0 will be used.
1008
-    * @return ImageHelper
1009
-    *
1010
-    * @throws ImageHelper_Exception
1011
-    * @see ImageHelper::ERROR_NOT_A_RESOURCE
1012
-    * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_CANVAS
1013
-    */
1002
+    /**
1003
+     * Trims the specified image resource by removing the specified color.
1004
+     * Also works with transparency.
1005
+     * 
1006
+     * @param resource $img
1007
+     * @param array|NULL $color A color definition, as an associative array with red, green, blue and alpha keys. If not specified, the color at pixel position 0,0 will be used.
1008
+     * @return ImageHelper
1009
+     *
1010
+     * @throws ImageHelper_Exception
1011
+     * @see ImageHelper::ERROR_NOT_A_RESOURCE
1012
+     * @see ImageHelper::ERROR_CANNOT_CREATE_IMAGE_CANVAS
1013
+     */
1014 1014
     protected function trimImage($img, ?array $color=null) : ImageHelper
1015 1015
     {
1016 1016
         if($this->isVector()) {
@@ -1118,14 +1118,14 @@  discard block
 block discarded – undo
1118 1118
         return $this;
1119 1119
     }
1120 1120
     
1121
-   /**
1122
-    * Requires the subject to be a resource.
1123
-    * 
1124
-    * @param resource|mixed $subject
1125
-    *
1126
-    * @throws ImageHelper_Exception
1127
-    * @see ImageHelper::ERROR_NOT_A_RESOURCE
1128
-    */
1121
+    /**
1122
+     * Requires the subject to be a resource.
1123
+     * 
1124
+     * @param resource|mixed $subject
1125
+     *
1126
+     * @throws ImageHelper_Exception
1127
+     * @see ImageHelper::ERROR_NOT_A_RESOURCE
1128
+     */
1129 1129
     protected static function requireResource($subject) : void
1130 1130
     {
1131 1131
         if(is_resource($subject)) {
@@ -1142,14 +1142,14 @@  discard block
 block discarded – undo
1142 1142
         );
1143 1143
     }
1144 1144
     
1145
-   /**
1146
-    * Creates a new image resource, with transparent background.
1147
-    * 
1148
-    * @param int $width
1149
-    * @param int $height
1150
-    * @throws ImageHelper_Exception
1151
-    * @return resource
1152
-    */
1145
+    /**
1146
+     * Creates a new image resource, with transparent background.
1147
+     * 
1148
+     * @param int $width
1149
+     * @param int $height
1150
+     * @throws ImageHelper_Exception
1151
+     * @return resource
1152
+     */
1153 1153
     protected function createNewImage(int $width, int $height)
1154 1154
     {
1155 1155
         $img = imagecreatetruecolor($width, $height);
@@ -1168,54 +1168,54 @@  discard block
 block discarded – undo
1168 1168
         return $img;
1169 1169
     }
1170 1170
     
1171
-   /**
1172
-    * Whether the two specified colors are the same.
1173
-    * 
1174
-    * @param array<string,int> $a
1175
-    * @param array<string,int> $b
1176
-    * @return boolean
1177
-    */
1178
-	protected function colorsMatch(array $a, array $b) : bool
1179
-	{
1180
-		$parts = array('red', 'green', 'blue');
1181
-		foreach($parts as $part) {
1182
-			if($a[$part] != $b[$part]) {
1183
-				return false;
1184
-			}
1185
-		} 
1171
+    /**
1172
+     * Whether the two specified colors are the same.
1173
+     * 
1174
+     * @param array<string,int> $a
1175
+     * @param array<string,int> $b
1176
+     * @return boolean
1177
+     */
1178
+    protected function colorsMatch(array $a, array $b) : bool
1179
+    {
1180
+        $parts = array('red', 'green', 'blue');
1181
+        foreach($parts as $part) {
1182
+            if($a[$part] != $b[$part]) {
1183
+                return false;
1184
+            }
1185
+        } 
1186 1186
 		
1187
-		return true;
1188
-	}
1187
+        return true;
1188
+    }
1189 1189
 	
1190
-	public function fillWhite($x=0, $y=0)
1191
-	{
1192
-	    $this->addRGBColor('white', 255, 255, 255);
1190
+    public function fillWhite($x=0, $y=0)
1191
+    {
1192
+        $this->addRGBColor('white', 255, 255, 255);
1193 1193
         return $this->fill('white', $x, $y);
1194
-	}
1194
+    }
1195 1195
 	
1196
-	public function fillTransparent() : ImageHelper
1197
-	{
1196
+    public function fillTransparent() : ImageHelper
1197
+    {
1198 1198
         $this->enableAlpha();
1199 1199
 	    
1200
-	    self::fillImageTransparent($this->newImage);
1200
+        self::fillImageTransparent($this->newImage);
1201 1201
 	    
1202
-	    return $this;
1203
-	}
1202
+        return $this;
1203
+    }
1204 1204
 	
1205
-	public static function fillImageTransparent($resource)
1206
-	{
1207
-	    self::requireResource($resource);
1205
+    public static function fillImageTransparent($resource)
1206
+    {
1207
+        self::requireResource($resource);
1208 1208
 	    
1209
-	    $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127);
1210
-	    imagecolortransparent ($resource, $transparent);
1211
-	    imagefill($resource, 0, 0, $transparent);
1212
-	}
1209
+        $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127);
1210
+        imagecolortransparent ($resource, $transparent);
1211
+        imagefill($resource, 0, 0, $transparent);
1212
+    }
1213 1213
 	
1214
-	public function fill($colorName, $x=0, $y=0)
1215
-	{
1216
-	    imagefill($this->newImage, $x, $y, $this->colors[$colorName]);
1217
-	    return $this;
1218
-	}
1214
+    public function fill($colorName, $x=0, $y=0)
1215
+    {
1216
+        imagefill($this->newImage, $x, $y, $this->colors[$colorName]);
1217
+        return $this;
1218
+    }
1219 1219
 	
1220 1220
     protected $colors = array();
1221 1221
 
@@ -1236,9 +1236,9 @@  discard block
 block discarded – undo
1236 1236
         return $this;
1237 1237
     }
1238 1238
     
1239
-   /**
1240
-    * @return resource
1241
-    */
1239
+    /**
1240
+     * @return resource
1241
+     */
1242 1242
     public function getImage()
1243 1243
     {
1244 1244
         return $this->newImage;
@@ -1256,26 +1256,26 @@  discard block
 block discarded – undo
1256 1256
         return $this;
1257 1257
     }
1258 1258
     
1259
-   /**
1260
-    * Retrieves the size of the image.
1261
-    * 
1262
-    * @return ImageHelper_Size
1263
-    * @throws ImageHelper_Exception
1264
-    * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE
1265
-    */
1266
-	public function getSize() : ImageHelper_Size
1259
+    /**
1260
+     * Retrieves the size of the image.
1261
+     * 
1262
+     * @return ImageHelper_Size
1263
+     * @throws ImageHelper_Exception
1264
+     * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE
1265
+     */
1266
+    public function getSize() : ImageHelper_Size
1267 1267
     {
1268
-	    return self::getImageSize($this->newImage);
1268
+        return self::getImageSize($this->newImage);
1269 1269
     }
1270 1270
     
1271 1271
     protected $TTFFile;
1272 1272
     
1273
-   /**
1274
-    * Sets the TTF font file to use for text operations.
1275
-    * 
1276
-    * @param string $filePath
1277
-    * @return ImageHelper
1278
-    */
1273
+    /**
1274
+     * Sets the TTF font file to use for text operations.
1275
+     * 
1276
+     * @param string $filePath
1277
+     * @return ImageHelper
1278
+     */
1279 1279
     public function setFontTTF($filePath)
1280 1280
     {
1281 1281
         $this->TTFFile = $filePath;
@@ -1347,63 +1347,63 @@  discard block
 block discarded – undo
1347 1347
             return;
1348 1348
         }
1349 1349
         
1350
-	    throw new ImageHelper_Exception(
1350
+        throw new ImageHelper_Exception(
1351 1351
             'No true type font specified',
1352 1352
             'This functionality requires a TTF font file to be specified with the [setFontTTF] method.',
1353 1353
             self::ERROR_NO_TRUE_TYPE_FONT_SET    
1354 1354
         );
1355 1355
     }
1356 1356
     
1357
-   /**
1358
-	 * Retrieves the size of an image file on disk, or
1359
-	 * an existing image resource.
1360
-	 *
1361
-	 * <pre>
1362
-	 * array(
1363
-	 *     0: (width),
1364
-	 *     1: (height),
1365
-	 *     "channels": the amount of channels
1366
-	 *     "bits": bits per channel
1357
+    /**
1358
+     * Retrieves the size of an image file on disk, or
1359
+     * an existing image resource.
1360
+     *
1361
+     * <pre>
1362
+     * array(
1363
+     *     0: (width),
1364
+     *     1: (height),
1365
+     *     "channels": the amount of channels
1366
+     *     "bits": bits per channel
1367 1367
      * )     
1368
-	 * </pre>
1369
-	 *
1370
-	 * @param string|resource $pathOrResource
1371
-	 * @return ImageHelper_Size Size object, can also be accessed like the traditional array from getimagesize
1372
-	 * @see ImageHelper_Size
1373
-	 * @throws ImageHelper_Exception
1374
-	 * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE
1375
-	 * @see ImageHelper::ERROR_CANNOT_READ_SVG_IMAGE
1376
-	 * @see ImageHelper::ERROR_SVG_SOURCE_VIEWBOX_MISSING
1377
-	 * @see ImageHelper::ERROR_SVG_VIEWBOX_INVALID
1378
-	 */
1379
-	public static function getImageSize($pathOrResource) : ImageHelper_Size
1380
-	{
1381
-	    if(is_resource($pathOrResource)) 
1382
-	    {
1383
-	        return new ImageHelper_Size(array(
1384
-	            'width' => imagesx($pathOrResource),
1385
-	            'height' => imagesy($pathOrResource),
1386
-	            'channels' => 1,
1387
-	            'bits' => 8
1388
-	        ));
1389
-	    }
1368
+     * </pre>
1369
+     *
1370
+     * @param string|resource $pathOrResource
1371
+     * @return ImageHelper_Size Size object, can also be accessed like the traditional array from getimagesize
1372
+     * @see ImageHelper_Size
1373
+     * @throws ImageHelper_Exception
1374
+     * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE
1375
+     * @see ImageHelper::ERROR_CANNOT_READ_SVG_IMAGE
1376
+     * @see ImageHelper::ERROR_SVG_SOURCE_VIEWBOX_MISSING
1377
+     * @see ImageHelper::ERROR_SVG_VIEWBOX_INVALID
1378
+     */
1379
+    public static function getImageSize($pathOrResource) : ImageHelper_Size
1380
+    {
1381
+        if(is_resource($pathOrResource)) 
1382
+        {
1383
+            return new ImageHelper_Size(array(
1384
+                'width' => imagesx($pathOrResource),
1385
+                'height' => imagesy($pathOrResource),
1386
+                'channels' => 1,
1387
+                'bits' => 8
1388
+            ));
1389
+        }
1390 1390
 	    
1391
-	    $type = self::getFileImageType($pathOrResource);
1391
+        $type = self::getFileImageType($pathOrResource);
1392 1392
 	    
1393
-	    $info = false;
1394
-	    $method = 'getImageSize_'.$type;
1395
-	    if(method_exists(__CLASS__, $method)) 
1396
-	    {
1397
-	        $info = call_user_func(array(__CLASS__, $method), $pathOrResource);
1398
-	    } 
1399
-	    else 
1400
-	    {
1401
-	        $info = getimagesize($pathOrResource);
1402
-	    }
1393
+        $info = false;
1394
+        $method = 'getImageSize_'.$type;
1395
+        if(method_exists(__CLASS__, $method)) 
1396
+        {
1397
+            $info = call_user_func(array(__CLASS__, $method), $pathOrResource);
1398
+        } 
1399
+        else 
1400
+        {
1401
+            $info = getimagesize($pathOrResource);
1402
+        }
1403 1403
 	    
1404
-	    if($info !== false) {
1405
-	        return new ImageHelper_Size($info);
1406
-	    }
1404
+        if($info !== false) {
1405
+            return new ImageHelper_Size($info);
1406
+        }
1407 1407
 	    
1408 1408
         throw new ImageHelper_Exception(
1409 1409
             'Error opening image file',
@@ -1413,98 +1413,98 @@  discard block
 block discarded – undo
1413 1413
             ),
1414 1414
             self::ERROR_CANNOT_GET_IMAGE_SIZE
1415 1415
         );
1416
-	}
1416
+    }
1417 1417
 	
1418
-   /**
1419
-    * @param string $imagePath
1420
-    * @throws ImageHelper_Exception
1421
-    * @return array
1422
-    * 
1423
-    * @todo This should return a ImageHelper_Size instance.
1424
-    */
1425
-	protected static function getImageSize_svg(string $imagePath) : array
1426
-	{
1427
-	    $xml = XMLHelper::createSimplexml();
1428
-	    $xml->loadFile($imagePath);
1418
+    /**
1419
+     * @param string $imagePath
1420
+     * @throws ImageHelper_Exception
1421
+     * @return array
1422
+     * 
1423
+     * @todo This should return a ImageHelper_Size instance.
1424
+     */
1425
+    protected static function getImageSize_svg(string $imagePath) : array
1426
+    {
1427
+        $xml = XMLHelper::createSimplexml();
1428
+        $xml->loadFile($imagePath);
1429 1429
 	    
1430
-	    if($xml->hasErrors()) {
1431
-	        throw new ImageHelper_Exception(
1432
-	            'Error opening SVG image',
1433
-	            sprintf(
1434
-	                'The XML content of the image [%s] could not be parsed.',
1435
-	                $imagePath
1430
+        if($xml->hasErrors()) {
1431
+            throw new ImageHelper_Exception(
1432
+                'Error opening SVG image',
1433
+                sprintf(
1434
+                    'The XML content of the image [%s] could not be parsed.',
1435
+                    $imagePath
1436 1436
                 ),
1437
-	            self::ERROR_CANNOT_READ_SVG_IMAGE
1437
+                self::ERROR_CANNOT_READ_SVG_IMAGE
1438 1438
             );
1439
-	    }
1439
+        }
1440 1440
 	    
1441
-	    $data = $xml->toArray();
1442
-	    $xml->dispose();
1443
-	    unset($xml);
1441
+        $data = $xml->toArray();
1442
+        $xml->dispose();
1443
+        unset($xml);
1444 1444
 	    
1445
-	    if(!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) {
1446
-	        throw new ImageHelper_Exception(
1447
-	            'SVG Image is corrupted',
1448
-	            sprintf(
1449
-	                'The [viewBox] attribute is missing in the XML of the image at path [%s].',
1450
-	                $imagePath
1445
+        if(!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) {
1446
+            throw new ImageHelper_Exception(
1447
+                'SVG Image is corrupted',
1448
+                sprintf(
1449
+                    'The [viewBox] attribute is missing in the XML of the image at path [%s].',
1450
+                    $imagePath
1451 1451
                 ),
1452
-	            self::ERROR_SVG_SOURCE_VIEWBOX_MISSING
1452
+                self::ERROR_SVG_SOURCE_VIEWBOX_MISSING
1453 1453
             );
1454
-	    }
1454
+        }
1455 1455
 	    
1456
-	    $svgWidth = parseNumber($data['@attributes']['width'])->getNumber();
1457
-	    $svgHeight = parseNumber($data['@attributes']['height'])->getNumber();
1456
+        $svgWidth = parseNumber($data['@attributes']['width'])->getNumber();
1457
+        $svgHeight = parseNumber($data['@attributes']['height'])->getNumber();
1458 1458
 	    
1459
-	    $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']);
1460
-	    $size = explode(',', $viewBox);
1459
+        $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']);
1460
+        $size = explode(',', $viewBox);
1461 1461
 	    
1462
-	    if(count($size) != 4) 
1463
-	    {
1464
-	        throw new ImageHelper_Exception(
1465
-	            'SVG image has an invalid viewBox attribute',
1466
-	            sprintf(
1467
-	               'The [viewBox] attribute does not have an expected value: [%s] in path [%s].',
1468
-	                $viewBox,
1469
-	                $imagePath
1462
+        if(count($size) != 4) 
1463
+        {
1464
+            throw new ImageHelper_Exception(
1465
+                'SVG image has an invalid viewBox attribute',
1466
+                sprintf(
1467
+                    'The [viewBox] attribute does not have an expected value: [%s] in path [%s].',
1468
+                    $viewBox,
1469
+                    $imagePath
1470 1470
                 ),
1471
-	            self::ERROR_SVG_VIEWBOX_INVALID
1471
+                self::ERROR_SVG_VIEWBOX_INVALID
1472 1472
             );
1473
-	    }
1473
+        }
1474 1474
 	    
1475
-	    $boxWidth = (float)$size[2];
1476
-	    $boxHeight = (float)$size[3];
1475
+        $boxWidth = (float)$size[2];
1476
+        $boxHeight = (float)$size[3];
1477 1477
 	    
1478
-	    // calculate the x and y units of the document: 
1479
-	    // @see http://tutorials.jenkov.com/svg/svg-viewport-view-box.html#viewbox
1480
-	    //
1481
-	    // The viewbox combined with the width and heigt of the svg
1482
-	    // allow calculating how many pixels are in one unit of the 
1483
-	    // width and height of the document.
1478
+        // calculate the x and y units of the document: 
1479
+        // @see http://tutorials.jenkov.com/svg/svg-viewport-view-box.html#viewbox
1480
+        //
1481
+        // The viewbox combined with the width and heigt of the svg
1482
+        // allow calculating how many pixels are in one unit of the 
1483
+        // width and height of the document.
1484 1484
         //
1485
-	    $xUnits = $svgWidth / $boxWidth;
1486
-	    $yUnits = $svgHeight / $boxHeight;
1485
+        $xUnits = $svgWidth / $boxWidth;
1486
+        $yUnits = $svgHeight / $boxHeight;
1487 1487
 	    
1488
-	    $pxWidth = $xUnits * $svgWidth;
1489
-	    $pxHeight = $yUnits * $svgHeight;
1488
+        $pxWidth = $xUnits * $svgWidth;
1489
+        $pxHeight = $yUnits * $svgHeight;
1490 1490
 	    
1491
-	    return array(
1492
-	        $pxWidth,
1493
-	        $pxHeight,
1494
-	        'bits' => 8
1495
-	    );
1496
-	}
1491
+        return array(
1492
+            $pxWidth,
1493
+            $pxHeight,
1494
+            'bits' => 8
1495
+        );
1496
+    }
1497 1497
 	
1498
-	/**
1499
-    * Crops the image to the specified width and height, optionally
1500
-    * specifying the origin position to crop from.
1501
-    * 
1502
-    * @param integer $width
1503
-    * @param integer $height
1504
-    * @param integer $x
1505
-    * @param integer $y
1506
-    * @return ImageHelper
1507
-    */
1498
+    /**
1499
+     * Crops the image to the specified width and height, optionally
1500
+     * specifying the origin position to crop from.
1501
+     * 
1502
+     * @param integer $width
1503
+     * @param integer $height
1504
+     * @param integer $x
1505
+     * @param integer $y
1506
+     * @return ImageHelper
1507
+     */
1508 1508
     public function crop(int $width, int $height, int $x=0, int $y=0) : ImageHelper
1509 1509
     {
1510 1510
         $new = $this->createNewImage($width, $height);
@@ -1526,22 +1526,22 @@  discard block
 block discarded – undo
1526 1526
         return $this->newHeight;
1527 1527
     }
1528 1528
 
1529
-   /**
1530
-    * Calculates the average color value used in 
1531
-    * the image. Returns an associative array
1532
-    * with the red, green, blue and alpha components,
1533
-    * or a HEX color string depending on the selected
1534
-    * format.
1535
-    * 
1536
-    * NOTE: Use the calcAverageColorXXX methods for
1537
-    * strict return types. 
1538
-    * 
1539
-    * @param int $format The format in which to return the color value.
1540
-    * @return array|string
1541
-    * 
1542
-    * @see ImageHelper::calcAverageColorRGB()
1543
-    * @see ImageHelper::calcAverageColorHEX()
1544
-    */
1529
+    /**
1530
+     * Calculates the average color value used in 
1531
+     * the image. Returns an associative array
1532
+     * with the red, green, blue and alpha components,
1533
+     * or a HEX color string depending on the selected
1534
+     * format.
1535
+     * 
1536
+     * NOTE: Use the calcAverageColorXXX methods for
1537
+     * strict return types. 
1538
+     * 
1539
+     * @param int $format The format in which to return the color value.
1540
+     * @return array|string
1541
+     * 
1542
+     * @see ImageHelper::calcAverageColorRGB()
1543
+     * @see ImageHelper::calcAverageColorHEX()
1544
+     */
1545 1545
     public function calcAverageColor(int $format=self::COLORFORMAT_RGB)
1546 1546
     {
1547 1547
         $image = $this->duplicate();
@@ -1550,35 +1550,35 @@  discard block
 block discarded – undo
1550 1550
         return $image->getColorAt(0, 0, $format);
1551 1551
     }
1552 1552
     
1553
-   /**
1554
-    * Calculates the image's average color value, and
1555
-    * returns an associative array with red, green,
1556
-    * blue and alpha keys.
1557
-    * 
1558
-    * @throws ImageHelper_Exception
1559
-    * @return array
1560
-    */
1553
+    /**
1554
+     * Calculates the image's average color value, and
1555
+     * returns an associative array with red, green,
1556
+     * blue and alpha keys.
1557
+     * 
1558
+     * @throws ImageHelper_Exception
1559
+     * @return array
1560
+     */
1561 1561
     public function calcAverageColorRGB() : array
1562 1562
     {
1563
-       $result = $this->calcAverageColor(self::COLORFORMAT_RGB);
1564
-       if(is_array($result)) {
1565
-           return $result;
1566
-       }
1563
+        $result = $this->calcAverageColor(self::COLORFORMAT_RGB);
1564
+        if(is_array($result)) {
1565
+            return $result;
1566
+        }
1567 1567
        
1568
-       throw new ImageHelper_Exception(
1569
-           'Unexpected color value',
1570
-           sprintf('Expected an array, got [%s].', gettype($result)),
1571
-           self::ERROR_UNEXPECTED_COLOR_VALUE
1572
-       );
1568
+        throw new ImageHelper_Exception(
1569
+            'Unexpected color value',
1570
+            sprintf('Expected an array, got [%s].', gettype($result)),
1571
+            self::ERROR_UNEXPECTED_COLOR_VALUE
1572
+        );
1573 1573
     }
1574 1574
     
1575
-   /**
1576
-    * Calculates the image's average color value, and
1577
-    * returns a hex color string (without the #).
1578
-    * 
1579
-    * @throws ImageHelper_Exception
1580
-    * @return string
1581
-    */
1575
+    /**
1576
+     * Calculates the image's average color value, and
1577
+     * returns a hex color string (without the #).
1578
+     * 
1579
+     * @throws ImageHelper_Exception
1580
+     * @return string
1581
+     */
1582 1582
     public function calcAverageColorHex() : string
1583 1583
     {
1584 1584
         $result = $this->calcAverageColor(self::COLORFORMAT_HEX);
@@ -1645,12 +1645,12 @@  discard block
 block discarded – undo
1645 1645
         return $rgb;
1646 1646
     }
1647 1647
     
1648
-   /**
1649
-    * Converts an RGB value to its luminance equivalent.
1650
-    * 
1651
-    * @param array<string,int> $rgb
1652
-    * @return integer Integer, from 0 to 255 (0=black, 255=white)
1653
-    */
1648
+    /**
1649
+     * Converts an RGB value to its luminance equivalent.
1650
+     * 
1651
+     * @param array<string,int> $rgb
1652
+     * @return integer Integer, from 0 to 255 (0=black, 255=white)
1653
+     */
1654 1654
     public static function rgb2luma(array $rgb) : int
1655 1655
     {
1656 1656
         return (int)floor((($rgb['red']*2)+$rgb['blue']+($rgb['green']*3))/6);
@@ -1670,15 +1670,15 @@  discard block
 block discarded – undo
1670 1670
         return $luma * 100 / 255;
1671 1671
     }
1672 1672
     
1673
-   /**
1674
-    * Retrieves an md5 hash of the source image file.
1675
-    * 
1676
-    * NOTE: Only works when the helper has been created
1677
-    * from a file. Otherwise, an exception is thrown.
1678
-    * 
1679
-    * @return string
1680
-    * @throws ImageHelper_Exception|OutputBuffering_Exception
1681
-    */
1673
+    /**
1674
+     * Retrieves an md5 hash of the source image file.
1675
+     * 
1676
+     * NOTE: Only works when the helper has been created
1677
+     * from a file. Otherwise, an exception is thrown.
1678
+     * 
1679
+     * @return string
1680
+     * @throws ImageHelper_Exception|OutputBuffering_Exception
1681
+     */
1682 1682
     public function getHash() : string
1683 1683
     {
1684 1684
         if($this->newImage === null)
Please login to merge, or discard this patch.
src/ConvertHelper/WordWrapper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
         return $this->getBoolOption('cut');
64 64
     }
65 65
     
66
-    public function setCuttingEnabled(bool $enabled=true) : ConvertHelper_WordWrapper
66
+    public function setCuttingEnabled(bool $enabled = true) : ConvertHelper_WordWrapper
67 67
     {
68 68
         $this->setOption('cut', $enabled);
69 69
         return $this;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -92,8 +92,7 @@
 block discarded – undo
92 92
                 if (mb_strlen($actual.$word) <= $width)
93 93
                 {
94 94
                     $actual .= $word.' ';
95
-                }
96
-                else
95
+                } else
97 96
                 {
98 97
                     if ($actual != '') {
99 98
                         $line .= rtrim($actual).$break;
Please login to merge, or discard this patch.
src/SVNHelper/CommandResult.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,37 +4,37 @@  discard block
 block discarded – undo
4 4
 
5 5
 class SVNHelper_CommandResult
6 6
 {
7
-   /**
8
-    * @var SVNHelper_Command
9
-    */
7
+    /**
8
+     * @var SVNHelper_Command
9
+     */
10 10
     protected $command;
11 11
     
12
-   /**
13
-    * @var string[]
14
-    */
12
+    /**
13
+     * @var string[]
14
+     */
15 15
     protected $output;
16 16
     
17
-   /**
18
-    * @var SVNHelper_CommandError[]
19
-    */
17
+    /**
18
+     * @var SVNHelper_CommandError[]
19
+     */
20 20
     protected $errors = array();
21 21
     
22
-   /**
23
-    * @var SVNHelper_CommandError[]
24
-    */
22
+    /**
23
+     * @var SVNHelper_CommandError[]
24
+     */
25 25
     protected $warnings = array();
26 26
     
27
-   /**
28
-    * The actual command that has been executed
29
-    * @var string
30
-    */
27
+    /**
28
+     * The actual command that has been executed
29
+     * @var string
30
+     */
31 31
     protected $commandLine;
32 32
     
33
-   /**
34
-    * @param SVNHelper_Command $command
35
-    * @param string[] $output
36
-    * @param SVNHelper_CommandError[] $errors
37
-    */
33
+    /**
34
+     * @param SVNHelper_Command $command
35
+     * @param string[] $output
36
+     * @param SVNHelper_CommandError[] $errors
37
+     */
38 38
     public function __construct(SVNHelper_Command $command, $commandLine, $output, $errors)
39 39
     {
40 40
         $this->command = $command;
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
         return $this->command;
87 87
     }
88 88
     
89
-   /**
90
-    * Retrieves all error messages.
91
-    * 
92
-    * @param bool $asString
93
-    * @return string|string[]
94
-    */
89
+    /**
90
+     * Retrieves all error messages.
91
+     * 
92
+     * @param bool $asString
93
+     * @return string|string[]
94
+     */
95 95
     public function getErrorMessages(bool $asString=false)
96 96
     {
97 97
         if($asString) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
         $this->commandLine = $commandLine;
42 42
         $this->output = $output;
43 43
         
44
-        foreach($errors as $error) {
45
-            if($error->isError()) {
44
+        foreach ($errors as $error) {
45
+            if ($error->isError()) {
46 46
                 $this->errors[] = $error;
47 47
             } else {
48 48
                 $this->warnings[] = $error;
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
     
63 63
     public function hasErrorCode($code)
64 64
     {
65
-        foreach($this->errors as $error) {
66
-            if($error->getCode() == $code) {
65
+        foreach ($this->errors as $error) {
66
+            if ($error->getCode() == $code) {
67 67
                 return true;
68 68
             }
69 69
         }
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     * @param bool $asString
93 93
     * @return string|string[]
94 94
     */
95
-    public function getErrorMessages(bool $asString=false)
95
+    public function getErrorMessages(bool $asString = false)
96 96
     {
97
-        if($asString) {
97
+        if ($asString) {
98 98
             $lines = array();
99
-            foreach($this->errors as $error) {
99
+            foreach ($this->errors as $error) {
100 100
                 $lines[] = (string)$error;
101 101
             }
102 102
             
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
         
106 106
         $messages = array();
107
-        foreach($this->errors as $error) {
107
+        foreach ($this->errors as $error) {
108 108
             $messages[] = (string)$error;
109 109
         }
110 110
         
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     
124 124
     public function getLastLine()
125 125
     {
126
-        return $this->output[count($this->output)-1];
126
+        return $this->output[count($this->output) - 1];
127 127
     }
128 128
     
129 129
     public function getFirstLine()
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
     
139 139
     public function isConnectionFailed()
140 140
     {
141
-        foreach($this->errors as $error) {
142
-            if($error->isConnectionFailed()) {
141
+        foreach ($this->errors as $error) {
142
+            if ($error->isConnectionFailed()) {
143 143
                 return true;
144 144
             }
145 145
         }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
     
150 150
     public function hasConflicts()
151 151
     {
152
-        foreach($this->errors as $error) {
153
-            if($error->isConflict()) {
152
+        foreach ($this->errors as $error) {
153
+            if ($error->isConflict()) {
154 154
                 return true;
155 155
             }
156 156
         }
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
     
161 161
     public function hasLocks()
162 162
     {
163
-        foreach($this->errors as $error) {
164
-            if($error->isLock()) {
163
+        foreach ($this->errors as $error) {
164
+            if ($error->isLock()) {
165 165
                 return true;
166 166
             }
167 167
         }
Please login to merge, or discard this patch.
src/ConvertHelper/ByteConverter.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class ConvertHelper_ByteConverter
25 25
 {
26
-   /**
27
-    * @var int
28
-    */
26
+    /**
27
+     * @var int
28
+     */
29 29
     protected $bytes;
30 30
     
31 31
     public function __construct(int $bytes)
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
         }
40 40
     }
41 41
     
42
-   /**
43
-    * Detects the size matching the byte value for the specified base.
44
-    * 
45
-    * @param int $base
46
-    * @return ConvertHelper_StorageSizeEnum_Size
47
-    */
42
+    /**
43
+     * Detects the size matching the byte value for the specified base.
44
+     * 
45
+     * @param int $base
46
+     * @return ConvertHelper_StorageSizeEnum_Size
47
+     */
48 48
     protected function detectSize(int $base) : ConvertHelper_StorageSizeEnum_Size
49 49
     {
50 50
         $sizes = $this->getSizesSorted($base);   
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
         return ConvertHelper_StorageSizeEnum::getSizeByName('b');
71 71
     }
72 72
     
73
-   /**
74
-    * Retrieves all storage sizes for the specified base, 
75
-    * sorted from smallest byte size to highest.
76
-    * 
77
-    * @param int $base
78
-    * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
79
-    */
73
+    /**
74
+     * Retrieves all storage sizes for the specified base, 
75
+     * sorted from smallest byte size to highest.
76
+     * 
77
+     * @param int $base
78
+     * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
79
+     */
80 80
     protected function getSizesSorted(int $base)
81 81
     {
82 82
         $sizes = ConvertHelper_StorageSizeEnum::getSizesByBase($base);
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
         return $sizes;
90 90
     }
91 91
     
92
-   /**
93
-    * Converts the byte value to a human readable string, e.g. "5 KB", "140 MB".
94
-    * 
95
-    * @param int $precision The amount of decimals (rounded up)
96
-    * @param int $base The base to calculate bytes with.
97
-    * @return string
98
-    * 
99
-    * @see ConvertHelper_StorageSizeEnum::BASE_10
100
-    * @see ConvertHelper_StorageSizeEnum::BASE_2
101
-    */
92
+    /**
93
+     * Converts the byte value to a human readable string, e.g. "5 KB", "140 MB".
94
+     * 
95
+     * @param int $precision The amount of decimals (rounded up)
96
+     * @param int $base The base to calculate bytes with.
97
+     * @return string
98
+     * 
99
+     * @see ConvertHelper_StorageSizeEnum::BASE_10
100
+     * @see ConvertHelper_StorageSizeEnum::BASE_2
101
+     */
102 102
     public function toString(int $precision, int $base=ConvertHelper_StorageSizeEnum::BASE_10) : string
103 103
     {
104 104
         $size = $this->detectSize($base);
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
         return round($this->bytes / $size->getBytes(), $precision) . ' ' . $size->getSuffix();
107 107
     }
108 108
     
109
-   /**
110
-    * Converts the byte value to the amount of the corresponding units (KB, MB...).
111
-    * 
112
-    * @param int $precision The amount of decimals (rounded up)
113
-    * @param string $sizeName The lowercase storage size name (e.g. "kb", "kib")
114
-    * @return float
115
-    */
109
+    /**
110
+     * Converts the byte value to the amount of the corresponding units (KB, MB...).
111
+     * 
112
+     * @param int $precision The amount of decimals (rounded up)
113
+     * @param string $sizeName The lowercase storage size name (e.g. "kb", "kib")
114
+     * @return float
115
+     */
116 116
     public function toNumber(int $precision, string $sizeName) : float
117 117
     {
118 118
         $size = ConvertHelper_StorageSizeEnum::getSizeByName($sizeName);
@@ -120,56 +120,56 @@  discard block
 block discarded – undo
120 120
         return round($this->bytes / $size->getBytes(), $precision);
121 121
     }
122 122
     
123
-   /**
124
-    * Converts the bytes to Kilobytes.
125
-    * 
126
-    * @param int $precision Amount of decimals (rounded up)
127
-    * @return float
128
-    */
123
+    /**
124
+     * Converts the bytes to Kilobytes.
125
+     * 
126
+     * @param int $precision Amount of decimals (rounded up)
127
+     * @return float
128
+     */
129 129
     public function toKilobytes(int $precision=1) : float
130 130
     {
131 131
         return $this->toNumber($precision, 'kb');
132 132
     }
133 133
     
134
-   /**
135
-    * Converts the bytes to Megabytes.
136
-    *
137
-    * @param int $precision Amount of decimals (rounded up)
138
-    * @return float
139
-    */
134
+    /**
135
+     * Converts the bytes to Megabytes.
136
+     *
137
+     * @param int $precision Amount of decimals (rounded up)
138
+     * @return float
139
+     */
140 140
     public function toMegabytes(int $precision=1) : float
141 141
     {
142 142
         return $this->toNumber($precision, 'mb');
143 143
     }
144 144
 
145
-   /**
146
-    * Converts the bytes to Gigabytes.
147
-    *
148
-    * @param int $precision Amount of decimals (rounded up)
149
-    * @return float
150
-    */
145
+    /**
146
+     * Converts the bytes to Gigabytes.
147
+     *
148
+     * @param int $precision Amount of decimals (rounded up)
149
+     * @return float
150
+     */
151 151
     public function toGigabytes(int $precision=1) : float
152 152
     {
153 153
         return $this->toNumber($precision, 'gb');
154 154
     }
155 155
 
156
-   /**
157
-    * Converts the bytes to Terabytes.
158
-    *
159
-    * @param int $precision Amount of decimals (rounded up)
160
-    * @return float
161
-    */
156
+    /**
157
+     * Converts the bytes to Terabytes.
158
+     *
159
+     * @param int $precision Amount of decimals (rounded up)
160
+     * @return float
161
+     */
162 162
     public function toTerabytes(int $precision=1) : float
163 163
     {
164 164
         return $this->toNumber($precision, 'tb');
165 165
     }
166 166
     
167
-   /**
168
-    * Converts the bytes to Petabytes.
169
-    *
170
-    * @param int $precision Amount of decimals (rounded up)
171
-    * @return float
172
-    */
167
+    /**
168
+     * Converts the bytes to Petabytes.
169
+     *
170
+     * @param int $precision Amount of decimals (rounded up)
171
+     * @return float
172
+     */
173 173
     public function toPetabytes(int $precision=1) : float
174 174
     {
175 175
         return $this->toNumber($precision, 'pb');
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $this->bytes = $bytes;
34 34
         
35 35
         // correct negative values
36
-        if($this->bytes < 0) 
36
+        if ($this->bytes < 0) 
37 37
         {
38 38
             $this->bytes = 0;
39 39
         }
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $sizes = $this->getSizesSorted($base);   
51 51
 
52
-        if($this->bytes >= $sizes[0]->getBytes()) 
52
+        if ($this->bytes >= $sizes[0]->getBytes()) 
53 53
         {
54 54
             $total = count($sizes);
55 55
             
56
-            for($i=0; $i < $total; $i++)
56
+            for ($i = 0; $i < $total; $i++)
57 57
             {
58 58
                 $size = $sizes[$i];
59 59
                 
60
-                if(!isset($sizes[($i+1)])) {
60
+                if (!isset($sizes[($i + 1)])) {
61 61
                     return $size;
62 62
                 }
63 63
                 
64
-                if($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i+1)]->getBytes()) {
64
+                if ($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i + 1)]->getBytes()) {
65 65
                     return $size;
66 66
                 }
67 67
             }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     * @see ConvertHelper_StorageSizeEnum::BASE_10
100 100
     * @see ConvertHelper_StorageSizeEnum::BASE_2
101 101
     */
102
-    public function toString(int $precision, int $base=ConvertHelper_StorageSizeEnum::BASE_10) : string
102
+    public function toString(int $precision, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string
103 103
     {
104 104
         $size = $this->detectSize($base);
105 105
         
106
-        return round($this->bytes / $size->getBytes(), $precision) . ' ' . $size->getSuffix();
106
+        return round($this->bytes / $size->getBytes(), $precision).' '.$size->getSuffix();
107 107
     }
108 108
     
109 109
    /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     * @param int $precision Amount of decimals (rounded up)
127 127
     * @return float
128 128
     */
129
-    public function toKilobytes(int $precision=1) : float
129
+    public function toKilobytes(int $precision = 1) : float
130 130
     {
131 131
         return $this->toNumber($precision, 'kb');
132 132
     }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     * @param int $precision Amount of decimals (rounded up)
138 138
     * @return float
139 139
     */
140
-    public function toMegabytes(int $precision=1) : float
140
+    public function toMegabytes(int $precision = 1) : float
141 141
     {
142 142
         return $this->toNumber($precision, 'mb');
143 143
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     * @param int $precision Amount of decimals (rounded up)
149 149
     * @return float
150 150
     */
151
-    public function toGigabytes(int $precision=1) : float
151
+    public function toGigabytes(int $precision = 1) : float
152 152
     {
153 153
         return $this->toNumber($precision, 'gb');
154 154
     }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     * @param int $precision Amount of decimals (rounded up)
160 160
     * @return float
161 161
     */
162
-    public function toTerabytes(int $precision=1) : float
162
+    public function toTerabytes(int $precision = 1) : float
163 163
     {
164 164
         return $this->toNumber($precision, 'tb');
165 165
     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     * @param int $precision Amount of decimals (rounded up)
171 171
     * @return float
172 172
     */
173
-    public function toPetabytes(int $precision=1) : float
173
+    public function toPetabytes(int $precision = 1) : float
174 174
     {
175 175
         return $this->toNumber($precision, 'pb');
176 176
     }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param int $precision Amount of decimals (rounded up)
182 182
      * @return float
183 183
      */
184
-    public function toKibibytes(int $precision=1) : float
184
+    public function toKibibytes(int $precision = 1) : float
185 185
     {
186 186
         return $this->toNumber($precision, 'kib');
187 187
     }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      * @param int $precision Amount of decimals (rounded up)
193 193
      * @return float
194 194
      */
195
-    public function toMebibytes(int $precision=1) : float
195
+    public function toMebibytes(int $precision = 1) : float
196 196
     {
197 197
         return $this->toNumber($precision, 'mib');
198 198
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @param int $precision Amount of decimals (rounded up)
204 204
      * @return float
205 205
      */
206
-    public function toGibibytes(int $precision=1) : float
206
+    public function toGibibytes(int $precision = 1) : float
207 207
     {
208 208
         return $this->toNumber($precision, 'gib');
209 209
     }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      * @param int $precision Amount of decimals (rounded up)
215 215
      * @return float
216 216
      */
217
-    public function toTebibytes(int $precision=1) : float
217
+    public function toTebibytes(int $precision = 1) : float
218 218
     {
219 219
         return $this->toNumber($precision, 'tib');
220 220
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * @param int $precision Amount of decimals (rounded up)
226 226
      * @return float
227 227
      */
228
-    public function toPebibytes(int $precision=1) : float
228
+    public function toPebibytes(int $precision = 1) : float
229 229
     {
230 230
         return $this->toNumber($precision, 'pib');
231 231
     }
Please login to merge, or discard this patch.
src/ConvertHelper/StorageSizeEnum/Size.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,34 +25,34 @@
 block discarded – undo
25 25
  */
26 26
 class ConvertHelper_StorageSizeEnum_Size
27 27
 {
28
-   /**
29
-    * @var string
30
-    */
28
+    /**
29
+     * @var string
30
+     */
31 31
     protected $name;
32 32
     
33
-   /**
34
-    * @var int
35
-    */
33
+    /**
34
+     * @var int
35
+     */
36 36
     protected $base;
37 37
     
38
-   /**
39
-    * @var int
40
-    */
38
+    /**
39
+     * @var int
40
+     */
41 41
     protected $exponent;
42 42
     
43
-   /**
44
-    * @var string
45
-    */
43
+    /**
44
+     * @var string
45
+     */
46 46
     protected $singular;
47 47
     
48
-   /**
49
-    * @var string
50
-    */
48
+    /**
49
+     * @var string
50
+     */
51 51
     protected $plural;
52 52
     
53
-   /**
54
-    * @var string
55
-    */
53
+    /**
54
+     * @var string
55
+     */
56 56
     protected $suffix;
57 57
     
58 58
     public function __construct(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural)
Please login to merge, or discard this patch.
src/ConvertHelper/SizeNotation.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     * @return string
100 100
     * @see ConvertHelper::bytes2readable()
101 101
     */
102
-    public function toString(int $precision=1) : string
102
+    public function toString(int $precision = 1) : string
103 103
     {
104 104
         return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase());
105 105
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     */
111 111
     public function getBase() : int
112 112
     {
113
-        if($this->isValid()) {
113
+        if ($this->isValid()) {
114 114
             return $this->sizeDefinition->getBase(); 
115 115
         }
116 116
         
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     */
127 127
     public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size
128 128
     {
129
-        if($this->isValid()) {
129
+        if ($this->isValid()) {
130 130
             return $this->sizeDefinition;
131 131
         }
132 132
         
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
     
176 176
     protected function parseSize() : void
177 177
     {
178
-        if(!$this->detectParts()) {
178
+        if (!$this->detectParts()) {
179 179
             return;
180 180
         }
181 181
         
182 182
         // we detected units in the string: all good.
183
-        if($this->units !== null)
183
+        if ($this->units !== null)
184 184
         {
185 185
             return;
186 186
         }
187 187
         
188 188
         // just a numeric value: we assume this means we're dealing with bytes.
189
-        if(is_numeric($this->number)) 
189
+        if (is_numeric($this->number)) 
190 190
         {
191 191
             $this->units = 'b';
192 192
             return;
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
         
213 213
         $number = $this->sizeString;
214 214
         
215
-        foreach($units as $unit)
215
+        foreach ($units as $unit)
216 216
         {
217
-            if(stristr($number, $unit))
217
+            if (stristr($number, $unit))
218 218
             {
219 219
                 // there are more than 1 unit defined in the string
220
-                if($this->units !== null)
220
+                if ($this->units !== null)
221 221
                 {
222 222
                     $this->setError(
223 223
                         t(
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
     {
274 274
         $this->parseSize();
275 275
         
276
-        if(!$this->valid) {
276
+        if (!$this->valid) {
277 277
             return;
278 278
         }
279 279
         
280 280
         $int = intval($this->number);
281 281
         
282 282
         // negative values
283
-        if($int < 0) 
283
+        if ($int < 0) 
284 284
         {
285 285
             $this->setError(
286 286
                 t('Negative values cannot be used as size.'),
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     
32 32
     public const VALIDATION_ERROR_NEGATIVE_VALUE = 43803;
33 33
     
34
-   /**
35
-    * @var string
36
-    */
34
+    /**
35
+     * @var string
36
+     */
37 37
     protected $sizeString;
38 38
 
39 39
     /**
@@ -41,44 +41,44 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected $sizeDefinition;
43 43
     
44
-   /**
45
-    * @var integer
46
-    */
44
+    /**
45
+     * @var integer
46
+     */
47 47
     protected $bytes = 0;
48 48
     
49
-   /**
50
-    * @var bool
51
-    */
49
+    /**
50
+     * @var bool
51
+     */
52 52
     protected $valid = true;
53 53
     
54
-   /**
55
-    * @var string
56
-    */
54
+    /**
55
+     * @var string
56
+     */
57 57
     protected $units = null;
58 58
     
59
-   /**
60
-    * @var string
61
-    */
59
+    /**
60
+     * @var string
61
+     */
62 62
     protected $number = '';
63 63
     
64
-   /**
65
-    * @var string
66
-    */
64
+    /**
65
+     * @var string
66
+     */
67 67
     protected $errorMessage = '';
68 68
     
69
-   /**
70
-    * @var int
71
-    */
69
+    /**
70
+     * @var int
71
+     */
72 72
     protected $errorCode = 0;
73 73
     
74
-   /**
75
-    * Create a new instance for the specified size string.
76
-    * 
77
-    * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = "  50   MB   ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case-insensitive, so "50 MB" = "50 mb".
78
-    *
79
-    * @throws ConvertHelper_Exception
80
-    * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME
81
-    */
74
+    /**
75
+     * Create a new instance for the specified size string.
76
+     * 
77
+     * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = "  50   MB   ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case-insensitive, so "50 MB" = "50 mb".
78
+     *
79
+     * @throws ConvertHelper_Exception
80
+     * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME
81
+     */
82 82
     public function __construct(string $sizeString)
83 83
     {
84 84
         $this->sizeString = $this->cleanString($sizeString);
@@ -86,31 +86,31 @@  discard block
 block discarded – undo
86 86
         $this->convert();
87 87
     }
88 88
     
89
-   /**
90
-    * Gets the amount of bytes contained in the size notation.
91
-    * @return int
92
-    */
89
+    /**
90
+     * Gets the amount of bytes contained in the size notation.
91
+     * @return int
92
+     */
93 93
     public function toBytes() : int
94 94
     {
95 95
         return $this->bytes;
96 96
     }
97 97
     
98
-   /**
99
-    * Converts the size notation to a human-readable string, e.g. "50 MB".
100
-    * 
101
-    * @param int $precision
102
-    * @return string
103
-    * @see ConvertHelper::bytes2readable()
104
-    */
98
+    /**
99
+     * Converts the size notation to a human-readable string, e.g. "50 MB".
100
+     * 
101
+     * @param int $precision
102
+     * @return string
103
+     * @see ConvertHelper::bytes2readable()
104
+     */
105 105
     public function toString(int $precision=1) : string
106 106
     {
107 107
         return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase());
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves the detected number's base.
112
-    * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid.
113
-    */
110
+    /**
111
+     * Retrieves the detected number's base.
112
+     * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid.
113
+     */
114 114
     public function getBase() : int
115 115
     {
116 116
         if($this->isValid()) {
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         return 0;
121 121
     }
122 122
     
123
-   /**
124
-    * Retrieves the detected storage size instance, if 
125
-    * the size string is valid.
126
-    * 
127
-    * @return ConvertHelper_StorageSizeEnum_Size|NULL
128
-    * @see ConvertHelper_StorageSizeEnum_Size
129
-    */
123
+    /**
124
+     * Retrieves the detected storage size instance, if 
125
+     * the size string is valid.
126
+     * 
127
+     * @return ConvertHelper_StorageSizeEnum_Size|NULL
128
+     * @see ConvertHelper_StorageSizeEnum_Size
129
+     */
130 130
     public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size
131 131
     {
132 132
         if($this->isValid()) {
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
         return null;
137 137
     }
138 138
     
139
-   /**
140
-    * Checks whether the size notation was valid and could be parsed
141
-    * into a meaningful byte value. If this returns `false`, it is 
142
-    * possible to use the `getErrorXXX` methods to retrieve information
143
-    * on what went wrong. 
144
-    * 
145
-    * @return bool
146
-    * @see ConvertHelper_SizeNotation::getErrorMessage()
147
-    * @see ConvertHelper_SizeNotation::getErrorCode()
148
-    */
139
+    /**
140
+     * Checks whether the size notation was valid and could be parsed
141
+     * into a meaningful byte value. If this returns `false`, it is 
142
+     * possible to use the `getErrorXXX` methods to retrieve information
143
+     * on what went wrong. 
144
+     * 
145
+     * @return bool
146
+     * @see ConvertHelper_SizeNotation::getErrorMessage()
147
+     * @see ConvertHelper_SizeNotation::getErrorCode()
148
+     */
149 149
     public function isValid() : bool
150 150
     {
151 151
         return $this->valid;
152 152
     }
153 153
     
154
-   /**
155
-    * Retrieves the error message if the size notation validation failed.
156
-    * 
157
-    * @return string
158
-    * @see ConvertHelper_SizeNotation::getErrorCode()
159
-    */
154
+    /**
155
+     * Retrieves the error message if the size notation validation failed.
156
+     * 
157
+     * @return string
158
+     * @see ConvertHelper_SizeNotation::getErrorCode()
159
+     */
160 160
     public function getErrorMessage() : string
161 161
     {
162 162
         return $this->errorMessage;
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
         );
202 202
     }
203 203
     
204
-   /**
205
-    * Detects the units and the number in the size notation string.
206
-    * Populates the `units` and `number` properties.
207
-    * 
208
-    * @return bool Whether the string could be parsed successfully.
209
-    */
204
+    /**
205
+     * Detects the units and the number in the size notation string.
206
+     * Populates the `units` and `number` properties.
207
+     * 
208
+     * @return bool Whether the string could be parsed successfully.
209
+     */
210 210
     protected function detectParts() : bool
211 211
     {
212 212
         $units = ConvertHelper_StorageSizeEnum::getSizeNames();
@@ -242,16 +242,16 @@  discard block
 block discarded – undo
242 242
         return true;
243 243
     }
244 244
     
245
-   /**
246
-    * If the validation fails, this is used to store the reason for retrieval later.
247
-    *  
248
-    * @param string $message
249
-    * @param int $code
250
-    * 
251
-    * @see ConvertHelper_SizeNotation::isValid()
252
-    * @see ConvertHelper_SizeNotation::getErrorMessage()
253
-    * @see ConvertHelper_SizeNotation::getErrorCode()
254
-    */
245
+    /**
246
+     * If the validation fails, this is used to store the reason for retrieval later.
247
+     *  
248
+     * @param string $message
249
+     * @param int $code
250
+     * 
251
+     * @see ConvertHelper_SizeNotation::isValid()
252
+     * @see ConvertHelper_SizeNotation::getErrorMessage()
253
+     * @see ConvertHelper_SizeNotation::getErrorCode()
254
+     */
255 255
     protected function setError(string $message, int $code) : void
256 256
     {
257 257
         $this->valid = false;
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
         $this->errorCode = $code;
260 260
     }
261 261
     
262
-   /**
263
-    * Retrieves the error code, if the size notation validation failed.
264
-    * 
265
-    * @return int
266
-    * @see ConvertHelper_SizeNotation::getErrorMessage()
267
-    */
262
+    /**
263
+     * Retrieves the error code, if the size notation validation failed.
264
+     * 
265
+     * @return int
266
+     * @see ConvertHelper_SizeNotation::getErrorMessage()
267
+     */
268 268
     public function getErrorCode() : int
269 269
     {
270 270
         return $this->errorCode;
Please login to merge, or discard this patch.
src/Request/AcceptHeaders.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
         $this->parse();
29 29
     }
30 30
     
31
-   /**
32
-    * Retrieves an indexed array with accept mime types
33
-    * that the client sent, in the order of preference
34
-    * the client specified.
35
-    *
36
-    * Example:
37
-    *
38
-    * array(
39
-    *     'text/html',
40
-    *     'application/xhtml+xml',
41
-    *     'image/webp'
42
-    *     ...
43
-    * )
44
-    */
31
+    /**
32
+     * Retrieves an indexed array with accept mime types
33
+     * that the client sent, in the order of preference
34
+     * the client specified.
35
+     *
36
+     * Example:
37
+     *
38
+     * array(
39
+     *     'text/html',
40
+     *     'application/xhtml+xml',
41
+     *     'image/webp'
42
+     *     ...
43
+     * )
44
+     */
45 45
     public function getMimeStrings() : array
46 46
     {
47 47
         $result = array();
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
         return $result;
55 55
     }
56 56
     
57
-   /**
58
-    * Checks that an accept header string exists, and tries to parse it.
59
-    */
57
+    /**
58
+     * Checks that an accept header string exists, and tries to parse it.
59
+     */
60 60
     protected function parse() : void
61 61
     {
62 62
         // we may be in a CLI environment where the headers
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
         $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']);
69 69
     }
70 70
     
71
-   /**
72
-    * Splits the accept header string and parses the mime types.
73
-    *  
74
-    * @param string $acceptHeader 
75
-    */
71
+    /**
72
+     * Splits the accept header string and parses the mime types.
73
+     *  
74
+     * @param string $acceptHeader 
75
+     */
76 76
     protected function parseHeader(string $acceptHeader) : array
77 77
     {
78 78
         $tokens = preg_split('/\s*,\s*/', $acceptHeader);
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
         return $accept;
90 90
     }
91 91
     
92
-   /**
93
-    * Parses a single mime type entry.
94
-    * 
95
-    * @param int $i The position in the accept string
96
-    * @param string $mime The mime type
97
-    * @return array
98
-    */
92
+    /**
93
+     * Parses a single mime type entry.
94
+     * 
95
+     * @param int $i The position in the accept string
96
+     * @param string $mime The mime type
97
+     * @return array
98
+     */
99 99
     protected function parseEntry(int $i, string $mime) : array
100 100
     {
101 101
         $entry = array(
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
         return $entry;
126 126
     }
127 127
     
128
-   /**
129
-    * Sorts the mime types collection, first by quality
130
-    * and then by position in the list.
131
-    * 
132
-    * @param array $a
133
-    * @param array $b
134
-    * @return number
135
-    */
128
+    /**
129
+     * Sorts the mime types collection, first by quality
130
+     * and then by position in the list.
131
+     * 
132
+     * @param array $a
133
+     * @param array $b
134
+     * @return number
135
+     */
136 136
     protected function sortMimeTypes(array $a, array $b)
137 137
     {
138 138
         /* first tier: highest q factor wins */
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $result = array();
48 48
         
49
-        foreach($this->headers as $header)
49
+        foreach ($this->headers as $header)
50 50
         {
51 51
             $result[] = $header['type'];
52 52
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         // we may be in a CLI environment where the headers
63 63
         // are not populated.
64
-        if(!isset($_SERVER['HTTP_ACCEPT'])) {
64
+        if (!isset($_SERVER['HTTP_ACCEPT'])) {
65 65
             return;
66 66
         }
67 67
         
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         
80 80
         $accept = array();
81 81
         
82
-        foreach($tokens as $i => $term)
82
+        foreach ($tokens as $i => $term)
83 83
         {
84 84
             $accept[] = $this->parseEntry($i, $term);
85 85
         }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             'type' => null
106 106
         );
107 107
         
108
-        if(strstr($mime, ';'))
108
+        if (strstr($mime, ';'))
109 109
         {
110 110
             $parts = explode(';', $mime);
111 111
             $mime = array_shift($parts);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             // like an URL query string if separated by ampersands;
115 115
             $entry['params'] = ConvertHelper::parseQueryString(implode('&', $parts));
116 116
                 
117
-            if(isset($entry['params']['q'])) 
117
+            if (isset($entry['params']['q'])) 
118 118
             {
119 119
                 $entry['quality'] = (double)$entry['params']['q'];
120 120
             } 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -141,14 +141,12 @@
 block discarded – undo
141 141
         if ($diff > 0) 
142 142
         {
143 143
             $diff = 1;
144
-        } 
145
-        else 
144
+        } else 
146 145
         {
147 146
             if ($diff < 0) 
148 147
             {
149 148
                 $diff = -1;
150
-            } 
151
-            else 
149
+            } else 
152 150
             {
153 151
                 /* tie-breaker: first listed item wins */
154 152
                 $diff = $a['pos'] - $b['pos'];
Please login to merge, or discard this patch.