Passed
Branch master (f6a670)
by Sebastian
07:16 queued 02:32
created
src/IniHelper/Section.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -21,19 +21,19 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class IniHelper_Section
23 23
 {
24
-   /**
25
-    * @var IniHelper
26
-    */
24
+    /**
25
+     * @var IniHelper
26
+     */
27 27
     protected $ini;
28 28
     
29
-   /**
30
-    * @var string
31
-    */
29
+    /**
30
+     * @var string
31
+     */
32 32
     protected $name;
33 33
     
34
-   /**
35
-    * @var IniHelper_Line[]
36
-    */
34
+    /**
35
+     * @var IniHelper_Line[]
36
+     */
37 37
     protected $lines = array();
38 38
     
39 39
     public function __construct(IniHelper $ini, string $name)
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
         $this->name = $name;
43 43
     }
44 44
     
45
-   /**
46
-    * The section's name.
47
-    * @return string
48
-    */
45
+    /**
46
+     * The section's name.
47
+     * @return string
48
+     */
49 49
     public function getName() : string
50 50
     {
51 51
         return $this->name;
52 52
     }
53 53
     
54
-   /**
55
-    * Whether this is the default section: this 
56
-    * is used internally to store all variables that
57
-    * are not in any specific section.
58
-    * 
59
-    * @return bool
60
-    */
54
+    /**
55
+     * Whether this is the default section: this 
56
+     * is used internally to store all variables that
57
+     * are not in any specific section.
58
+     * 
59
+     * @return bool
60
+     */
61 61
     public function isDefault() : bool
62 62
     {
63 63
         return $this->name === IniHelper::SECTION_DEFAULT;
64 64
     }
65 65
     
66
-   /**
67
-    * Adds a line instance to the section.
68
-    * 
69
-    * @param IniHelper_Line $line
70
-    * @return IniHelper_Section
71
-    */
66
+    /**
67
+     * Adds a line instance to the section.
68
+     * 
69
+     * @param IniHelper_Line $line
70
+     * @return IniHelper_Section
71
+     */
72 72
     public function addLine(IniHelper_Line $line) : IniHelper_Section
73 73
     {
74 74
         $this->lines[] = $line;
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
         return $this;
77 77
     }
78 78
     
79
-   /**
80
-    * Converts the values contained in the section into 
81
-    * an associative array.
82
-    * 
83
-    * @return array
84
-    */
79
+    /**
80
+     * Converts the values contained in the section into 
81
+     * an associative array.
82
+     * 
83
+     * @return array
84
+     */
85 85
     public function toArray() : array
86 86
     {
87 87
         $result = array();
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
         return $result;
115 115
     }
116 116
     
117
-   /**
118
-    * Converts the section's lines into an INI string.
119
-    * 
120
-    * @return string
121
-    */
117
+    /**
118
+     * Converts the section's lines into an INI string.
119
+     * 
120
+     * @return string
121
+     */
122 122
     public function toString()
123 123
     {
124 124
         $lines = array();
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
         return implode($this->ini->getEOLChar(), $lines);
141 141
     }
142 142
 
143
-   /**
144
-    * Deletes a line from the section.
145
-    * 
146
-    * @param IniHelper_Line $toDelete
147
-    * @return IniHelper_Section
148
-    */
143
+    /**
144
+     * Deletes a line from the section.
145
+     * 
146
+     * @param IniHelper_Line $toDelete
147
+     * @return IniHelper_Section
148
+     */
149 149
     public function deleteLine(IniHelper_Line $toDelete) : IniHelper_Section
150 150
     {
151 151
         $keep = array();
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
         return $this;
163 163
     }
164 164
     
165
-   /**
166
-    * Sets the value of a variable, overwriting any existing value.
167
-    * 
168
-    * @param string $name
169
-    * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value.
170
-    * @return IniHelper_Section
171
-    */
165
+    /**
166
+     * Sets the value of a variable, overwriting any existing value.
167
+     * 
168
+     * @param string $name
169
+     * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value.
170
+     * @return IniHelper_Section
171
+     */
172 172
     public function setValue(string $name, $value) : IniHelper_Section
173 173
     {
174 174
         $lines = $this->getLinesByVariable($name);
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
         return $this;
230 230
     }
231 231
     
232
-   /**
233
-    * Adds a variable value to the section. Unlike setValue(), this
234
-    * will not overwrite any existing value. If the name is an existing
235
-    * variable name, it will be converted to duplicate keys.
236
-    * 
237
-    * @param string $name
238
-    * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added.
239
-    * @return IniHelper_Section
240
-    */
232
+    /**
233
+     * Adds a variable value to the section. Unlike setValue(), this
234
+     * will not overwrite any existing value. If the name is an existing
235
+     * variable name, it will be converted to duplicate keys.
236
+     * 
237
+     * @param string $name
238
+     * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added.
239
+     * @return IniHelper_Section
240
+     */
241 241
     public function addValue(string $name, $value) : IniHelper_Section
242 242
     {
243 243
         // array value? Treat it as duplicate keys.
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
     }
296 296
     
297 297
     
298
-   /**
299
-    * Retrieves all lines for the specified variable name.
300
-    *  
301
-    * @param string $name
302
-    * @return \AppUtils\IniHelper_Line[]
303
-    */
298
+    /**
299
+     * Retrieves all lines for the specified variable name.
300
+     *  
301
+     * @param string $name
302
+     * @return \AppUtils\IniHelper_Line[]
303
+     */
304 304
     public function getLinesByVariable(string $name)
305 305
     {
306 306
         $result = array();
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $result = array();
88 88
         
89
-        foreach($this->lines as $line)
89
+        foreach ($this->lines as $line)
90 90
         {
91
-            if(!$line->isValue()) {
91
+            if (!$line->isValue()) {
92 92
                 continue;
93 93
             }
94 94
 
95 95
             $name = $line->getVarName();
96 96
             
97
-            if(!isset($result[$name])) 
97
+            if (!isset($result[$name])) 
98 98
             {
99 99
                 $result[$name] = $line->getVarValue();
100 100
                 continue;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             // name exists in collection? Then this is a
104 104
             // duplicate key and we need to convert it to
105 105
             // an indexed array of values.
106
-            if(!is_array($result[$name])) 
106
+            if (!is_array($result[$name])) 
107 107
             {
108 108
                 $result[$name] = array($result[$name]);
109 109
             }
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
     public function toString()
123 123
     {
124 124
         $lines = array();
125
-        if(!$this->isDefault()) 
125
+        if (!$this->isDefault()) 
126 126
         {
127 127
             $lines[] = '['.$this->getName().']';
128 128
         }
129 129
         
130
-        foreach($this->lines as $line) 
130
+        foreach ($this->lines as $line) 
131 131
         {
132 132
             // we already did this
133
-            if($line->isSection()) {
133
+            if ($line->isSection()) {
134 134
                 continue;
135 135
             }
136 136
             
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $keep = array();
152 152
         
153
-        foreach($this->lines as $line)
153
+        foreach ($this->lines as $line)
154 154
         {
155
-            if($line !== $toDelete) {
155
+            if ($line !== $toDelete) {
156 156
                 $keep[] = $line;
157 157
             }
158 158
         }
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
         // Removes any superfluous values that may
178 178
         // already exist, if there are more than the
179 179
         // new set of values.
180
-        if(is_array($value))
180
+        if (is_array($value))
181 181
         {
182 182
             $values = array_values($value);
183 183
             $amountNew = count($values);
184 184
             $amountExisting = count($lines);
185 185
             
186 186
             $max = $amountNew;
187
-            if($amountExisting > $max) {
187
+            if ($amountExisting > $max) {
188 188
                 $max = $amountExisting;
189 189
             }
190 190
             
191
-            for($i=0; $i < $max; $i++) 
191
+            for ($i = 0; $i < $max; $i++) 
192 192
             {
193 193
                 // new value exists
194
-                if(isset($values[$i]))
194
+                if (isset($values[$i]))
195 195
                 {
196
-                    if(isset($lines[$i])) {
196
+                    if (isset($lines[$i])) {
197 197
                         $lines[$i]->setValue($values[$i]);
198 198
                     } else {
199 199
                         $this->addValueLine($name, $values[$i]);
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
         else
212 212
         {
213 213
             // remove all superfluous lines
214
-            if(!empty($lines))
214
+            if (!empty($lines))
215 215
             {
216 216
                 $line = array_shift($lines); // keep only the first line
217 217
                 $line->setValue($value);
218 218
                 
219
-                foreach($lines as $delete) {
219
+                foreach ($lines as $delete) {
220 220
                     $this->deleteLine($delete);
221 221
                 }
222 222
             }
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
     public function addValue(string $name, $value) : IniHelper_Section
242 242
     {
243 243
         // array value? Treat it as duplicate keys.
244
-        if(is_array($value))
244
+        if (is_array($value))
245 245
         {
246 246
             $values = array_values($value);
247 247
             
248
-            foreach($values as $setValue)
248
+            foreach ($values as $setValue)
249 249
             {
250 250
                 $this->addValue($name, $setValue);
251 251
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         
256 256
         $lines = $this->getLinesByVariable($name);
257 257
         
258
-        if(empty($lines))
258
+        if (empty($lines))
259 259
         {
260 260
             $this->addValueLine($name, $value);
261 261
         }
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
         {
264 264
             $found = false;
265 265
             
266
-            foreach($lines as $line)
266
+            foreach ($lines as $line)
267 267
             {
268
-                if($line->getVarValue() === $value) {
268
+                if ($line->getVarValue() === $value) {
269 269
                     $found = $line;
270 270
                     break;
271 271
                 }
272 272
             }
273 273
             
274
-            if(!$found)
274
+            if (!$found)
275 275
             {
276 276
                 $this->addValueLine($name, $value);
277 277
             }
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
     {
306 306
         $result = array();
307 307
         
308
-        foreach($this->lines as $line)
308
+        foreach ($this->lines as $line)
309 309
         {
310
-            if($line->isValue() && $line->getVarName() === $name) {
310
+            if ($line->isValue() && $line->getVarName() === $name) {
311 311
                 $result[] = $line;
312 312
             }
313 313
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -198,8 +198,7 @@  discard block
 block discarded – undo
198 198
                     } else {
199 199
                         $this->addValueLine($name, $values[$i]);
200 200
                     }
201
-                }
202
-                else 
201
+                } else 
203 202
                 {
204 203
                     $this->deleteLine($lines[$i]);
205 204
                 }
@@ -219,8 +218,7 @@  discard block
 block discarded – undo
219 218
                 foreach($lines as $delete) {
220 219
                     $this->deleteLine($delete);
221 220
                 }
222
-            }
223
-            else 
221
+            } else 
224 222
             {
225 223
                 $this->addValueLine($name, $value);
226 224
             }
@@ -258,8 +256,7 @@  discard block
 block discarded – undo
258 256
         if(empty($lines))
259 257
         {
260 258
             $this->addValueLine($name, $value);
261
-        }
262
-        else
259
+        } else
263 260
         {
264 261
             $found = false;
265 262
             
Please login to merge, or discard this patch.
src/CSVHelper/Builder.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
         return $this->setOption('separatorChar', $char);
18 18
     }
19 19
     
20
-    public function setTrailingNewline($useNewline=true)
20
+    public function setTrailingNewline($useNewline = true)
21 21
     {
22 22
         return $this->setOption('trailingNewline', $useNewline);
23 23
     }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             $args = $args[0];
39 39
         }
40 40
 
41
-        $this->lines[] = '"' . implode('"'.$this->getOption('separatorChar').'"', $args) . '"';
41
+        $this->lines[] = '"'.implode('"'.$this->getOption('separatorChar').'"', $args).'"';
42 42
         
43 43
         return $this;
44 44
     }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $csv = implode(PHP_EOL, $this->lines);
56 56
 
57
-        if($this->getOption('trailingNewline')) {
57
+        if ($this->getOption('trailingNewline')) {
58 58
             $csv .= PHP_EOL;
59 59
         }
60 60
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     
66 66
     public function setOption($name, $value)
67 67
     {
68
-        if(!isset($this->options)) {
68
+        if (!isset($this->options)) {
69 69
             $this->options = $this->getDefaultOptions();
70 70
         }
71 71
         
@@ -75,20 +75,20 @@  discard block
 block discarded – undo
75 75
     
76 76
     public function setOptions($options)
77 77
     {
78
-        foreach($options as $name => $value) {
78
+        foreach ($options as $name => $value) {
79 79
             $this->setOption($name, $value);
80 80
         }
81 81
         
82 82
         return $this;
83 83
     }
84 84
     
85
-    public function getOption($name, $default=null)
85
+    public function getOption($name, $default = null)
86 86
     {
87
-        if(!isset($this->options)) {
87
+        if (!isset($this->options)) {
88 88
             $this->options = $this->getDefaultOptions();
89 89
         }
90 90
         
91
-        if(isset($this->options[$name])) {
91
+        if (isset($this->options[$name])) {
92 92
             return $this->options[$name];
93 93
         }
94 94
         
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     
98 98
     public function hasOption($name)
99 99
     {
100
-        if(!isset($this->options)) {
100
+        if (!isset($this->options)) {
101 101
             $this->options = $this->getDefaultOptions();
102 102
         }
103 103
         
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     
107 107
     public function getOptions()
108 108
     {
109
-        if(!isset($this->options)) {
109
+        if (!isset($this->options)) {
110 110
             $this->options = $this->getDefaultOptions();
111 111
         }
112 112
         
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     
116 116
     public function isOption($name, $value)
117 117
     {
118
-        if($this->getOption($name) === $value) {
118
+        if ($this->getOption($name) === $value) {
119 119
             return true;
120 120
         }
121 121
         
Please login to merge, or discard this patch.
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.
examples/URLInfo/highlighting.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
  * @author Sebastian Mordziol <[email protected]>
8 8
  */
9 9
 
10
-   /**
11
-    * Examples environment config
12
-    */
10
+    /**
11
+     * Examples environment config
12
+     */
13 13
     require_once '../prepend.php';
14 14
 
15 15
     use function AppUtils\parseURL;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 		<br>
43 43
         <?php
44 44
         
45
-            foreach($urls as $url)
45
+            foreach ($urls as $url)
46 46
             {
47 47
                 $info = parseURL($url);
48 48
                 
Please login to merge, or discard this patch.
examples/prepend.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@
 block discarded – undo
17 17
         die('<b>ERROR:</b> Autoloader not present. Run composer update first.');
18 18
     }
19 19
     
20
-   /**
21
-    * The composer autoloader
22
-    */
20
+    /**
21
+     * The composer autoloader
22
+     */
23 23
     require_once $autoload;
24 24
 
25
-   /**
26
-    * Translation global function.
27
-    * @return string
28
-    */
25
+    /**
26
+     * Translation global function.
27
+     * @return string
28
+     */
29 29
     function t()
30 30
     {
31 31
         return call_user_func_array('\AppLocalize\t', func_get_args());
32 32
     }
33 33
     
34
-   /**
35
-    * Translation global function.
36
-    * @return string
37
-    */
34
+    /**
35
+     * Translation global function.
36
+     * @return string
37
+     */
38 38
     function pt()
39 39
     {
40 40
         return call_user_func_array('\AppLocalize\pt', func_get_args());
41 41
     }
42 42
     
43
-   /**
44
-    * Translation global function.
45
-    * @return string
46
-    */
43
+    /**
44
+     * Translation global function.
45
+     * @return string
46
+     */
47 47
     function pts()
48 48
     {
49 49
         return call_user_func_array('\AppLocalize\pts', func_get_args());
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     $autoload = realpath($root.'/../vendor/autoload.php');
13 13
     
14 14
     // we need the autoloader to be present
15
-    if($autoload === false) 
15
+    if ($autoload === false) 
16 16
     {
17 17
         die('<b>ERROR:</b> Autoloader not present. Run composer update first.');
18 18
     }
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 = $size[2];
1476
-	    $boxHeight = $size[3];
1475
+        $boxWidth = $size[2];
1476
+        $boxHeight = $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.