Test Failed
Push — master ( d4f358...fd5375 )
by Sebastian
14:10
created
src/XMLHelper/Converter/Decorator.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class XMLHelper_Converter_Decorator implements \JsonSerializable
23 23
 {
24
-   /**
25
-    * @var \SimpleXMLElement
26
-    */
24
+    /**
25
+     * @var \SimpleXMLElement
26
+     */
27 27
     private $subject;
28 28
     
29 29
     const DEF_DEPTH = 512;
30 30
     
31
-   /**
32
-    * @var array
33
-    */
31
+    /**
32
+     * @var array
33
+     */
34 34
     private $options = array(
35 35
         '@attributes' => true,
36 36
         '@text' => true,
37 37
         'depth' => self::DEF_DEPTH
38 38
     );
39 39
 
40
-   /**
41
-    * @var array|string|null
42
-    */
40
+    /**
41
+     * @var array|string|null
42
+     */
43 43
     protected $result = array();
44 44
     
45 45
     public function __construct(\SimpleXMLElement $element)
@@ -47,36 +47,36 @@  discard block
 block discarded – undo
47 47
         $this->subject = $element;
48 48
     }
49 49
     
50
-   /**
51
-    * Whether to use the `@attributes` key to store element attributes.
52
-    * 
53
-    * @param bool $bool
54
-    * @return XMLHelper_Converter_Decorator
55
-    */
50
+    /**
51
+     * Whether to use the `@attributes` key to store element attributes.
52
+     * 
53
+     * @param bool $bool
54
+     * @return XMLHelper_Converter_Decorator
55
+     */
56 56
     public function useAttributes(bool $bool) : XMLHelper_Converter_Decorator 
57 57
     {
58 58
         $this->options['@attributes'] = (bool)$bool;
59 59
         return $this;
60 60
     }
61 61
     
62
-   /**
63
-    * Whether to use the `@text` key to store the node text.
64
-    * 
65
-    * @param bool $bool
66
-    * @return XMLHelper_Converter_Decorator
67
-    */
62
+    /**
63
+     * Whether to use the `@text` key to store the node text.
64
+     * 
65
+     * @param bool $bool
66
+     * @return XMLHelper_Converter_Decorator
67
+     */
68 68
     public function useText(bool $bool) : XMLHelper_Converter_Decorator 
69 69
     {
70 70
         $this->options['@text'] = (bool)$bool;
71 71
         return $this;
72 72
     }
73 73
     
74
-   /**
75
-    * Set the maximum depth to parse in the document.
76
-    * 
77
-    * @param int $depth
78
-    * @return XMLHelper_Converter_Decorator
79
-    */
74
+    /**
75
+     * Set the maximum depth to parse in the document.
76
+     * 
77
+     * @param int $depth
78
+     * @return XMLHelper_Converter_Decorator
79
+     */
80 80
     public function setDepth(int $depth) : XMLHelper_Converter_Decorator 
81 81
     {
82 82
         $this->options['depth'] = (int)max(0, $depth);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     
108 108
     protected function detectAttributes()
109 109
     {
110
-        if(!$this->options['@attributes']) {
110
+        if (!$this->options['@attributes']) {
111 111
             return;
112 112
         }
113 113
         
114 114
         $attributes = $this->subject->attributes();
115 115
         
116
-        if(!empty($attributes)) 
116
+        if (!empty($attributes)) 
117 117
         {
118 118
             $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes));
119 119
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $children = $this->subject;
125 125
         $depth = $this->options['depth'] - 1;
126 126
         
127
-        if($depth <= 0) 
127
+        if ($depth <= 0) 
128 128
         {
129 129
             $children = [];
130 130
         }
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
             
138 138
             $decorator->options = ['depth' => $depth] + $this->options;
139 139
             
140
-            if(isset($this->result[$name])) 
140
+            if (isset($this->result[$name])) 
141 141
             {
142
-                if(!is_array($this->result[$name])) 
142
+                if (!is_array($this->result[$name])) 
143 143
                 {
144 144
                     $this->result[$name] = [$this->result[$name]];
145 145
                 }
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
         // json encode non-whitespace element simplexml text values.
159 159
         $text = trim((string)$this->subject);
160 160
         
161
-        if(strlen($text)) 
161
+        if (strlen($text)) 
162 162
         {
163
-            if($this->options['@text']) 
163
+            if ($this->options['@text']) 
164 164
             {
165 165
                 $this->result['@text'] = $text;
166 166
             } 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
                 }
146 146
                 
147 147
                 $this->result[$name][] = $decorator;
148
-            } 
149
-            else 
148
+            } else 
150 149
             {
151 150
                 $this->result[$name] = $decorator;
152 151
             }
@@ -163,8 +162,7 @@  discard block
 block discarded – undo
163 162
             if($this->options['@text']) 
164 163
             {
165 164
                 $this->result['@text'] = $text;
166
-            } 
167
-            else 
165
+            } else 
168 166
             {
169 167
                 $this->result = $text;
170 168
             }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  * @param mixed $value
17 17
  * @return \AppUtils\NumberInfo
18 18
  */
19
-function parseNumber($value, $forceNew=false)
19
+function parseNumber($value, $forceNew = false)
20 20
 {
21
-    if($value instanceof NumberInfo && $forceNew !== true) {
21
+    if ($value instanceof NumberInfo && $forceNew !== true) {
22 22
         return $value;
23 23
     }
24 24
     
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     $args = func_get_args();
100 100
     
101 101
     // is the localization package installed?
102
-    if(class_exists('\AppLocalize\Localization')) 
102
+    if (class_exists('\AppLocalize\Localization')) 
103 103
     {
104 104
         return call_user_func_array('\AppLocalize\t', $args);
105 105
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function requireCURL() : void
119 119
 {
120
-    if(function_exists('curl_init')) {
120
+    if (function_exists('curl_init')) {
121 121
         return;
122 122
     }
123 123
     
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  */
136 136
 function init()
137 137
 {
138
-    if(!class_exists('\AppLocalize\Localization')) {
138
+    if (!class_exists('\AppLocalize\Localization')) {
139 139
         return;
140 140
     }
141 141
     
Please login to merge, or discard this patch.
src/FileHelper/FileFinder.php 3 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
     
34 34
     const PATH_MODE_STRIP = 'strip';
35 35
     
36
-   /**
37
-    * @var string
38
-    */
36
+    /**
37
+     * @var string
38
+     */
39 39
     protected $path;
40 40
     
41
-   /**
42
-    * @var array
43
-    */
41
+    /**
42
+     * @var array
43
+     */
44 44
     protected $found;
45 45
     
46
-   /**
47
-    * The path must exist when the class is instantiated: its
48
-    * real path will be determined to work with.
49
-    * 
50
-    * @param string $path The absolute path to the target folder.
51
-    * @throws FileHelper_Exception
52
-    * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST
53
-    */
46
+    /**
47
+     * The path must exist when the class is instantiated: its
48
+     * real path will be determined to work with.
49
+     * 
50
+     * @param string $path The absolute path to the target folder.
51
+     * @throws FileHelper_Exception
52
+     * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST
53
+     */
54 54
     public function __construct(string $path)
55 55
     {
56 56
         $real = realpath($path);
@@ -82,66 +82,66 @@  discard block
 block discarded – undo
82 82
         );
83 83
     }
84 84
     
85
-   /**
86
-    * Enables extension stripping, to return file names without extension.
87
-    * 
88
-    * @return FileHelper_FileFinder
89
-    */
85
+    /**
86
+     * Enables extension stripping, to return file names without extension.
87
+     * 
88
+     * @return FileHelper_FileFinder
89
+     */
90 90
     public function stripExtensions() : FileHelper_FileFinder
91 91
     {
92 92
         return $this->setOption('strip-extensions', true);
93 93
     }
94 94
     
95
-   /**
96
-    * Enables recursing into subfolders.
97
-    * 
98
-    * @return FileHelper_FileFinder
99
-    */
95
+    /**
96
+     * Enables recursing into subfolders.
97
+     * 
98
+     * @return FileHelper_FileFinder
99
+     */
100 100
     public function makeRecursive() : FileHelper_FileFinder
101 101
     {
102 102
         return $this->setOption('recursive', true);
103 103
     }
104 104
     
105
-   /**
106
-    * Retrieves all extensions that were added to
107
-    * the include list.
108
-    * 
109
-    * @return array
110
-    */
105
+    /**
106
+     * Retrieves all extensions that were added to
107
+     * the include list.
108
+     * 
109
+     * @return array
110
+     */
111 111
     public function getIncludeExtensions() : array
112 112
     {
113 113
         return $this->getArrayOption('include-extensions');
114 114
     }
115 115
     
116
-   /**
117
-    * Includes a single extension in the file search: only
118
-    * files with this extension will be used in the results.
119
-    * 
120
-    * NOTE: Included extensions take precedence before excluded
121
-    * extensions. If any excluded extensions are specified, they
122
-    * will be ignored.
123
-    * 
124
-    * @param string $extension Extension name, without dot (`php` for example).
125
-    * @return FileHelper_FileFinder
126
-    * @see FileHelper_FileFinder::includeExtensions()
127
-    */
116
+    /**
117
+     * Includes a single extension in the file search: only
118
+     * files with this extension will be used in the results.
119
+     * 
120
+     * NOTE: Included extensions take precedence before excluded
121
+     * extensions. If any excluded extensions are specified, they
122
+     * will be ignored.
123
+     * 
124
+     * @param string $extension Extension name, without dot (`php` for example).
125
+     * @return FileHelper_FileFinder
126
+     * @see FileHelper_FileFinder::includeExtensions()
127
+     */
128 128
     public function includeExtension(string $extension) : FileHelper_FileFinder
129 129
     {
130 130
         return $this->includeExtensions(array($extension));
131 131
     }
132 132
     
133
-   /**
134
-    * Includes several extensions in the file search: only
135
-    * files with these extensions wil be used in the results.
136
-    * 
137
-    * NOTE: Included extensions take precedence before excluded
138
-    * extensions. If any excluded extensions are specified, they
139
-    * will be ignored.
140
-    * 
141
-    * @param array $extensions Extension names, without dot (`php` for example).
142
-    * @return FileHelper_FileFinder
143
-    * @see FileHelper_FileFinder::includeExtension()
144
-    */
133
+    /**
134
+     * Includes several extensions in the file search: only
135
+     * files with these extensions wil be used in the results.
136
+     * 
137
+     * NOTE: Included extensions take precedence before excluded
138
+     * extensions. If any excluded extensions are specified, they
139
+     * will be ignored.
140
+     * 
141
+     * @param array $extensions Extension names, without dot (`php` for example).
142
+     * @return FileHelper_FileFinder
143
+     * @see FileHelper_FileFinder::includeExtension()
144
+     */
145 145
     public function includeExtensions(array $extensions) : FileHelper_FileFinder
146 146
     {
147 147
         $items = $this->getIncludeExtensions();
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
         return $this;
153 153
     }
154 154
 
155
-   /**
156
-    * Retrieves a list of all extensions currently set as 
157
-    * excluded from the search.
158
-    * 
159
-    * @return array
160
-    */
155
+    /**
156
+     * Retrieves a list of all extensions currently set as 
157
+     * excluded from the search.
158
+     * 
159
+     * @return array
160
+     */
161 161
     public function getExcludeExtensions() : array
162 162
     {
163 163
         return $this->getArrayOption('exclude-extensions');
164 164
     }
165 165
     
166
-   /**
167
-    * Excludes a single extension from the search.
168
-    * 
169
-    * @param string $extension Extension name, without dot (`php` for example).
170
-    * @return FileHelper_FileFinder
171
-    * @see FileHelper_FileFinder::excludeExtensions()
172
-    */
166
+    /**
167
+     * Excludes a single extension from the search.
168
+     * 
169
+     * @param string $extension Extension name, without dot (`php` for example).
170
+     * @return FileHelper_FileFinder
171
+     * @see FileHelper_FileFinder::excludeExtensions()
172
+     */
173 173
     public function excludeExtension(string $extension) : FileHelper_FileFinder
174 174
     {
175 175
         return $this->excludeExtensions(array($extension));
176 176
     }
177 177
 
178
-   /**
179
-    * Add several extensions to the list of extensions to
180
-    * exclude from the file search.
181
-    *  
182
-    * @param array $extensions Extension names, without dot (`php` for example).
183
-    * @return FileHelper_FileFinder
184
-    * @see FileHelper_FileFinder::excludeExtension()
185
-    */
178
+    /**
179
+     * Add several extensions to the list of extensions to
180
+     * exclude from the file search.
181
+     *  
182
+     * @param array $extensions Extension names, without dot (`php` for example).
183
+     * @return FileHelper_FileFinder
184
+     * @see FileHelper_FileFinder::excludeExtension()
185
+     */
186 186
     public function excludeExtensions(array $extensions) : FileHelper_FileFinder
187 187
     {
188 188
         $items = $this->getExcludeExtensions();
@@ -193,52 +193,52 @@  discard block
 block discarded – undo
193 193
         return $this;
194 194
     }
195 195
     
196
-   /**
197
-    * In this mode, the entire path to the file will be stripped,
198
-    * leaving only the file name in the files list.
199
-    * 
200
-    * @return FileHelper_FileFinder
201
-    */
196
+    /**
197
+     * In this mode, the entire path to the file will be stripped,
198
+     * leaving only the file name in the files list.
199
+     * 
200
+     * @return FileHelper_FileFinder
201
+     */
202 202
     public function setPathmodeStrip() : FileHelper_FileFinder
203 203
     {
204 204
         return $this->setPathmode(self::PATH_MODE_STRIP);
205 205
     }
206 206
     
207
-   /**
208
-    * In this mode, only the path relative to the source folder
209
-    * will be included in the files list.
210
-    * 
211
-    * @return FileHelper_FileFinder
212
-    */
207
+    /**
208
+     * In this mode, only the path relative to the source folder
209
+     * will be included in the files list.
210
+     * 
211
+     * @return FileHelper_FileFinder
212
+     */
213 213
     public function setPathmodeRelative() : FileHelper_FileFinder
214 214
     {
215 215
         return $this->setPathmode(self::PATH_MODE_RELATIVE);
216 216
     }
217 217
     
218
-   /**
219
-    * In this mode, the full, absolute paths to the files will
220
-    * be included in the files list.
221
-    * 
222
-    * @return FileHelper_FileFinder
223
-    */
218
+    /**
219
+     * In this mode, the full, absolute paths to the files will
220
+     * be included in the files list.
221
+     * 
222
+     * @return FileHelper_FileFinder
223
+     */
224 224
     public function setPathmodeAbsolute() : FileHelper_FileFinder
225 225
     {
226 226
         return $this->setPathmode(self::PATH_MODE_ABSOLUTE);
227 227
     }
228 228
     
229
-   /**
230
-    * This sets a character or string to replace the slashes
231
-    * in the paths with. 
232
-    * 
233
-    * This is used for example in the `getPHPClassNames()` 
234
-    * method, to return files from subfolders as class names
235
-    * using the "_" character:
236
-    * 
237
-    * Subfolder/To/File.php => Subfolder_To_File.php
238
-    * 
239
-    * @param string $character
240
-    * @return \AppUtils\FileHelper_FileFinder
241
-    */
229
+    /**
230
+     * This sets a character or string to replace the slashes
231
+     * in the paths with. 
232
+     * 
233
+     * This is used for example in the `getPHPClassNames()` 
234
+     * method, to return files from subfolders as class names
235
+     * using the "_" character:
236
+     * 
237
+     * Subfolder/To/File.php => Subfolder_To_File.php
238
+     * 
239
+     * @param string $character
240
+     * @return \AppUtils\FileHelper_FileFinder
241
+     */
242 242
     public function setSlashReplacement(string $character) : FileHelper_FileFinder
243 243
     {
244 244
         return $this->setOption('slash-replacement', $character);
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
         return $this->setOption('pathmode', $mode);
250 250
     }
251 251
     
252
-   /**
253
-    * Retrieves a list of all matching file names/paths,
254
-    * depending on the selected options.
255
-    * 
256
-    * @return array
257
-    */
252
+    /**
253
+     * Retrieves a list of all matching file names/paths,
254
+     * depending on the selected options.
255
+     * 
256
+     * @return array
257
+     */
258 258
     public function getAll() : array
259 259
     {
260 260
         $this->find($this->path, true);
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
         return $this->found;
263 263
     }
264 264
     
265
-   /**
266
-    * Retrieves only PHP files. Can be combined with other
267
-    * options like enabling recursion into subfolders.
268
-    * 
269
-    * @return array
270
-    */
265
+    /**
266
+     * Retrieves only PHP files. Can be combined with other
267
+     * options like enabling recursion into subfolders.
268
+     * 
269
+     * @return array
270
+     */
271 271
     public function getPHPFiles() : array
272 272
     {
273 273
         $this->includeExtensions(array('php'));
274 274
         return $this->getAll();
275 275
     }
276 276
     
277
-   /**
278
-    * Generates PHP class names from file paths: it replaces
279
-    * slashes with underscores, and removes file extensions.
280
-    * 
281
-    * @return array An array of PHP file names without extension.
282
-    */
277
+    /**
278
+     * Generates PHP class names from file paths: it replaces
279
+     * slashes with underscores, and removes file extensions.
280
+     * 
281
+     * @return array An array of PHP file names without extension.
282
+     */
283 283
     public function getPHPClassNames() : array
284 284
     {
285 285
         $this->includeExtensions(array('php'));
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
         return $path;
351 351
     }
352 352
     
353
-   /**
354
-    * Checks whether the specified extension is allowed 
355
-    * with the current settings.
356
-    * 
357
-    * @param string $extension
358
-    * @return bool
359
-    */
353
+    /**
354
+     * Checks whether the specified extension is allowed 
355
+     * with the current settings.
356
+     * 
357
+     * @param string $extension
358
+     * @return bool
359
+     */
360 360
     protected function filterExclusion(string $extension) : bool
361 361
     {
362 362
         $include = $this->getOption('include-extensions');
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
         return true;
379 379
     }
380 380
     
381
-   /**
382
-    * Adjusts the path according to the selected path mode.
383
-    * 
384
-    * @param string $path
385
-    * @return string
386
-    */
381
+    /**
382
+     * Adjusts the path according to the selected path mode.
383
+     * 
384
+     * @param string $path
385
+     * @return string
386
+     */
387 387
     protected function filterPath(string $path) : string
388 388
     {
389 389
         switch($this->getStringOption('pathmode'))
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @see FileHelper_FileFinder
8 8
  */
9 9
 
10
-declare(strict_types = 1);
10
+declare(strict_types=1);
11 11
 
12 12
 namespace AppUtils;
13 13
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $real = realpath($path);
57 57
         
58
-        if($real === false) 
58
+        if ($real === false) 
59 59
         {
60 60
             throw new FileHelper_Exception(
61 61
                 'Target path does not exist',
@@ -290,22 +290,22 @@  discard block
 block discarded – undo
290 290
         return $this->getAll();
291 291
     }
292 292
     
293
-    protected function find(string $path, bool $isRoot=false) : void
293
+    protected function find(string $path, bool $isRoot = false) : void
294 294
     {
295
-        if($isRoot) {
295
+        if ($isRoot) {
296 296
             $this->found = array();
297 297
         }
298 298
         
299 299
         $recursive = $this->getBoolOption('recursive');
300 300
         
301 301
         $d = new \DirectoryIterator($path);
302
-        foreach($d as $item)
302
+        foreach ($d as $item)
303 303
         {
304 304
             $pathname = $item->getPathname();
305 305
             
306
-            if($item->isDir())
306
+            if ($item->isDir())
307 307
             {
308
-                if($recursive && !$item->isDot()) {
308
+                if ($recursive && !$item->isDot()) {
309 309
                     $this->find($pathname);
310 310
                 }
311 311
                 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             
315 315
             $file = $this->filterFile($pathname);
316 316
             
317
-            if($file !== null) 
317
+            if ($file !== null) 
318 318
             {
319 319
                 $this->found[] = $file;
320 320
             }
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
         
328 328
         $extension = FileHelper::getExtension($path);
329 329
         
330
-        if(!$this->filterExclusion($extension)) {
330
+        if (!$this->filterExclusion($extension)) {
331 331
             return null;
332 332
         }
333 333
         
334 334
         $path = $this->filterPath($path);
335 335
         
336
-        if($this->getOption('strip-extensions') === true)
336
+        if ($this->getOption('strip-extensions') === true)
337 337
         {
338 338
             $path = str_replace('.'.$extension, '', $path);
339 339
         }
340 340
         
341
-        if($path === '') {
341
+        if ($path === '') {
342 342
             return null;
343 343
         }
344 344
         
345 345
         $replace = $this->getOption('slash-replacement');
346
-        if(!empty($replace)) {
346
+        if (!empty($replace)) {
347 347
             $path = str_replace('/', $replace, $path);
348 348
         }
349 349
         
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
         $include = $this->getOption('include-extensions');
363 363
         $exclude = $this->getOption('exclude-extensions');
364 364
         
365
-        if(!empty($include))
365
+        if (!empty($include))
366 366
         {
367
-            if(!in_array($extension, $include)) {
367
+            if (!in_array($extension, $include)) {
368 368
                 return false;
369 369
             }
370 370
         }
371
-        else if(!empty($exclude))
371
+        else if (!empty($exclude))
372 372
         {
373
-            if(in_array($extension, $exclude)) {
373
+            if (in_array($extension, $exclude)) {
374 374
                 return false;
375 375
             }
376 376
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     */
387 387
     protected function filterPath(string $path) : string
388 388
     {
389
-        switch($this->getStringOption('pathmode'))
389
+        switch ($this->getStringOption('pathmode'))
390 390
         {
391 391
             case self::PATH_MODE_STRIP:
392 392
                 return basename($path);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -367,8 +367,7 @@
 block discarded – undo
367 367
             if(!in_array($extension, $include)) {
368 368
                 return false;
369 369
             }
370
-        }
371
-        else if(!empty($exclude))
370
+        } else if(!empty($exclude))
372 371
         {
373 372
             if(in_array($extension, $exclude)) {
374 373
                 return false;
Please login to merge, or discard this patch.
src/Request/URLComparer.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -23,44 +23,44 @@
 block discarded – undo
23 23
  */
24 24
 class Request_URLComparer
25 25
 {
26
-   /**
27
-    * @var Request
28
-    */
26
+    /**
27
+     * @var Request
28
+     */
29 29
     protected $request;
30 30
     
31
-   /**
32
-    * @var string
33
-    */
31
+    /**
32
+     * @var string
33
+     */
34 34
     protected $sourceURL;
35 35
     
36
-   /**
37
-    * @var string
38
-    */
36
+    /**
37
+     * @var string
38
+     */
39 39
     protected $targetURL;
40 40
     
41
-   /**
42
-    * @var array
43
-    */
41
+    /**
42
+     * @var array
43
+     */
44 44
     protected $limitParams = array();
45 45
     
46
-   /**
47
-    * @var bool
48
-    */
46
+    /**
47
+     * @var bool
48
+     */
49 49
     protected $isMatch = false;
50 50
     
51
-   /**
52
-    * @var bool
53
-    */
51
+    /**
52
+     * @var bool
53
+     */
54 54
     protected $ignoreFragment = true;
55 55
 
56
-   /**
57
-    * @var URLInfo
58
-    */
56
+    /**
57
+     * @var URLInfo
58
+     */
59 59
     protected $sourceInfo;
60 60
     
61
-   /**
62
-    * @var URLInfo
63
-    */
61
+    /**
62
+     * @var URLInfo
63
+     */
64 64
     protected $targetInfo;
65 65
     
66 66
     public function __construct(Request $request, string $sourceURL, string $targetURL)
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     
80 80
     public function addLimitParam(string $name) : Request_URLComparer
81 81
     {
82
-        if(!in_array($name, $this->limitParams)) {
82
+        if (!in_array($name, $this->limitParams)) {
83 83
             $this->limitParams[] = $name;
84 84
         }
85 85
         
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
     
89 89
     public function addLimitParams(array $names) : Request_URLComparer
90 90
     {
91
-        foreach($names as $name) {
91
+        foreach ($names as $name) {
92 92
             $this->addLimitParam($name);
93 93
         }
94 94
         
95 95
         return $this;
96 96
     }
97 97
     
98
-    public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer
98
+    public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer
99 99
     {
100 100
         $this->ignoreFragment = $ignore;
101 101
         return $this;
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
             'query' 
122 122
         );
123 123
         
124
-        if(!$this->ignoreFragment) {
124
+        if (!$this->ignoreFragment) {
125 125
             $keys[] = 'fragment';
126 126
         }
127 127
         
128
-        foreach($keys as $key)
128
+        foreach ($keys as $key)
129 129
         {
130
-            if(!$this->compareKey($key)) {
130
+            if (!$this->compareKey($key)) {
131 131
                 return false;
132 132
             }
133 133
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         
143 143
         $filter = 'filter_'.$key;
144 144
         
145
-        if(method_exists($this, $filter)) 
145
+        if (method_exists($this, $filter)) 
146 146
         {
147 147
             $sVal = $this->$filter($sVal);
148 148
             $tVal = $this->$filter($tVal);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     protected function filter_path(string $path) : string
155 155
     {
156 156
         // fix double slashes in URLs
157
-        while(stristr($path, '//')) {
157
+        while (stristr($path, '//')) {
158 158
             $path = str_replace('//', '/', $path);
159 159
         }
160 160
         
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     
164 164
     protected function filter_query(string $query) : string
165 165
     {
166
-        if(empty($query)) {
166
+        if (empty($query)) {
167 167
             return '';
168 168
         }
169 169
         
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
     
179 179
     protected function limitParams(array $params) : array
180 180
     {
181
-        if(empty($this->limitParams)) {
181
+        if (empty($this->limitParams)) {
182 182
             return $params;
183 183
         }
184 184
         
185 185
         $keep = array();
186 186
         
187
-        foreach($this->limitParams as $name)
187
+        foreach ($this->limitParams as $name)
188 188
         {
189
-            if(isset($params[$name])) {
189
+            if (isset($params[$name])) {
190 190
                 $keep[$name] = $params[$name];
191 191
             }
192 192
         }
Please login to merge, or discard this patch.
src/NumberInfo.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -572,8 +572,7 @@
 block discarded – undo
572 572
             {
573 573
                 $number = null;
574 574
                 $empty = true;
575
-            }
576
-            else
575
+            } else
577 576
             {
578 577
                 $number = (float)$number * 1;
579 578
             }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function setValue($value) : NumberInfo
86 86
     {
87
-        if($value instanceof NumberInfo) {
87
+        if ($value instanceof NumberInfo) {
88 88
             $value = $value->getValue();
89 89
         }
90 90
         
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     
118 118
     public function isPositive() : bool
119 119
     {
120
-        if(!$this->isEmpty()) {
120
+        if (!$this->isEmpty()) {
121 121
             $number = $this->getNumber();
122 122
             return $number > 0;
123 123
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function hasValue() : bool
150 150
     {
151
-        if(!$this->isEmpty() && !$this->isZero()) {
151
+        if (!$this->isEmpty() && !$this->isZero()) {
152 152
             return true;
153 153
         }
154 154
         
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function getUnits()
223 223
     {
224
-        if(!$this->hasUnits()) {
224
+        if (!$this->hasUnits()) {
225 225
             return 'px';
226 226
         }
227 227
         
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function toAttribute() : string
257 257
     {
258
-        if($this->isEmpty()) {
258
+        if ($this->isEmpty()) {
259 259
             return '';
260 260
         }
261 261
         
262
-        if($this->isZero()) {
262
+        if ($this->isZero()) {
263 263
             return '0';
264 264
         }
265 265
         
266
-        if($this->isPercent()) {
266
+        if ($this->isPercent()) {
267 267
             return $this->getNumber().$this->getUnits();
268 268
         }
269 269
         
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function toCSS() : string
278 278
     {
279
-        if($this->isEmpty()) {
279
+        if ($this->isEmpty()) {
280 280
             return '';
281 281
         }
282 282
         
283
-        if($this->isZero()) {
283
+        if ($this->isZero()) {
284 284
             return '0';
285 285
         }
286 286
         
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     
290 290
     public function __toString()
291 291
     {
292
-        if($this->isEmpty()) {
292
+        if ($this->isEmpty()) {
293 293
             return '';
294 294
         }
295 295
         
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     public function isBiggerThan($number)
308 308
     {
309 309
         $number = parseNumber($number);
310
-        if($number->getUnits() != $this->getUnits()) {
310
+        if ($number->getUnits() != $this->getUnits()) {
311 311
             return false;
312 312
         }
313 313
         
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     public function isSmallerThan($number)
326 326
     {
327 327
         $number = parseNumber($number);
328
-        if($number->getUnits() != $this->getUnits()) {
328
+        if ($number->getUnits() != $this->getUnits()) {
329 329
             return false;
330 330
         }
331 331
         
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     public function isBiggerEqual($number)
336 336
     {
337 337
         $number = parseNumber($number);
338
-        if($number->getUnits() != $this->getUnits()) {
338
+        if ($number->getUnits() != $this->getUnits()) {
339 339
             return false;
340 340
         }
341 341
         
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
      */
353 353
     public function add($value)
354 354
     {
355
-        if($this->isEmpty()) {
355
+        if ($this->isEmpty()) {
356 356
             $this->setValue($value);
357 357
             return $this;
358 358
         }
359 359
         
360 360
         $number = parseNumber($value);
361 361
         
362
-        if($number->getUnits() == $this->getUnits() || !$number->hasUnits())
362
+        if ($number->getUnits() == $this->getUnits() || !$number->hasUnits())
363 363
         {
364 364
             $new = $this->getNumber() + $number->getNumber();
365 365
             $this->setValue($new.$this->getUnits());
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
      */
379 379
     public function subtract($value)
380 380
     {
381
-        if($this->isEmpty()) {
381
+        if ($this->isEmpty()) {
382 382
             $this->setValue($value);
383 383
             return $this;
384 384
         }
385 385
         
386 386
         $number = parseNumber($value);
387 387
         
388
-        if($number->getUnits() == $this->getUnits() || !$number->hasUnits())
388
+        if ($number->getUnits() == $this->getUnits() || !$number->hasUnits())
389 389
         {
390 390
             $new = $this->getNumber() - $number->getNumber();
391 391
             $this->setValue($new.$this->getUnits());
@@ -412,25 +412,25 @@  discard block
 block discarded – undo
412 412
     
413 413
     protected function percentOperation($operation, $percent)
414 414
     {
415
-        if($this->isZeroOrEmpty()) {
415
+        if ($this->isZeroOrEmpty()) {
416 416
             return $this;
417 417
         }
418 418
         
419 419
         $percent = parseNumber($percent);
420
-        if($percent->hasUnits() && !$percent->isPercent()) {
420
+        if ($percent->hasUnits() && !$percent->isPercent()) {
421 421
             return $this;
422 422
         }
423 423
         
424 424
         $number = $this->getNumber();
425 425
         $value = $number * $percent->getNumber() / 100;
426 426
         
427
-        if($operation == '-') {
427
+        if ($operation == '-') {
428 428
             $number = $number - $value;
429 429
         } else {
430 430
             $number = $number + $value;
431 431
         }
432 432
         
433
-        if($this->isUnitInteger()) {
433
+        if ($this->isUnitInteger()) {
434 434
             $number = intval($number);
435 435
         }
436 436
         
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
         
482 482
         $key = $this->createValueKey($value);
483 483
 
484
-        if(array_key_exists($key, $cache)) {
484
+        if (array_key_exists($key, $cache)) {
485 485
             return $cache[$key];
486 486
         }
487 487
         
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
             'number' => null
492 492
         );
493 493
         
494
-        if($key === '_EMPTY_') 
494
+        if ($key === '_EMPTY_') 
495 495
         {
496 496
             $cache[$key]['empty'] = true;
497 497
             return $cache[$key];
498 498
         }
499 499
         
500
-        if($value === 0 || $value === '0') 
500
+        if ($value === 0 || $value === '0') 
501 501
         {
502 502
             $cache[$key]['number'] = 0;
503 503
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -506,20 +506,20 @@  discard block
 block discarded – undo
506 506
         
507 507
         $test = trim((string)$value);
508 508
         
509
-        if($test === '') 
509
+        if ($test === '') 
510 510
         {
511 511
             $cache[$key]['empty'] = true;
512 512
             return $cache[$key];
513 513
         }
514 514
         
515 515
         // replace comma notation (which is only possible if it's a string)
516
-        if(is_string($value))
516
+        if (is_string($value))
517 517
         {
518 518
             $test = $this->preProcess($test, $cache, $value);
519 519
         }
520 520
         
521 521
         // convert to a number if it's numeric
522
-        if(is_numeric($test)) 
522
+        if (is_numeric($test)) 
523 523
         {
524 524
             $cache[$key]['number'] = (float)$test * 1;
525 525
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -545,19 +545,19 @@  discard block
 block discarded – undo
545 545
         $empty = false;
546 546
         
547 547
         $found = $this->findUnits($test);
548
-        if($found !== null) 
548
+        if ($found !== null) 
549 549
         {
550 550
             $number = $found['number'];
551 551
             $units = $found['units'];
552 552
         }
553 553
         
554 554
         // the filters have to restore the value
555
-        if($this->postProcess)
555
+        if ($this->postProcess)
556 556
         {
557 557
             $number = $this->postProcess($number, $test);
558 558
         }
559 559
         // empty number
560
-        else if($number === '' || $number === null || is_bool($number))
560
+        else if ($number === '' || $number === null || is_bool($number))
561 561
         {
562 562
             $number = null;
563 563
             $empty = true;
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             $number = trim($number);
569 569
             
570 570
             // may be an arbitrary string in some cases
571
-            if(!is_numeric($number))
571
+            if (!is_numeric($number))
572 572
             {
573 573
                 $number = null;
574 574
                 $empty = true;
@@ -600,17 +600,17 @@  discard block
 block discarded – undo
600 600
         $vlength = strlen($value);
601 601
         $names = array_keys($this->knownUnits);
602 602
         
603
-        foreach($names as $unit)
603
+        foreach ($names as $unit)
604 604
         {
605 605
             $ulength = strlen($unit);
606
-            $start = $vlength-$ulength;
607
-            if($start < 0) {
606
+            $start = $vlength - $ulength;
607
+            if ($start < 0) {
608 608
                 continue;
609 609
             }
610 610
             
611 611
             $search = substr($value, $start, $ulength);
612 612
             
613
-            if($search==$unit) 
613
+            if ($search == $unit) 
614 614
             {
615 615
                 return array(
616 616
                     'units' => $unit,
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
     */
631 631
     private function createValueKey($value) : string
632 632
     {
633
-        if(!is_string($value) && !is_numeric($value))
633
+        if (!is_string($value) && !is_numeric($value))
634 634
         {
635 635
             return '_EMPTY_';
636 636
         }
@@ -696,12 +696,12 @@  discard block
 block discarded – undo
696 696
     protected function filterInfo(array $info) : array
697 697
     {
698 698
         $useUnits = 'px';
699
-        if($info['units'] !== null) {
699
+        if ($info['units'] !== null) {
700 700
             $useUnits = $info['units'];
701 701
         }
702 702
         
703 703
         // the units are non-decimal: convert decimal values
704
-        if($useUnits !== null && $this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
704
+        if ($useUnits !== null && $this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
705 705
         {
706 706
             $info['number'] = intval($info['number']);
707 707
         }
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -38,24 +38,24 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class NumberInfo
40 40
 {
41
-   /**
42
-    * @var mixed
43
-    */
41
+    /**
42
+     * @var mixed
43
+     */
44 44
     protected $rawValue;
45 45
     
46
-   /**
47
-    * @var array
48
-    */
46
+    /**
47
+     * @var array
48
+     */
49 49
     protected $info;
50 50
     
51
-   /**
52
-    * @var bool
53
-    */
51
+    /**
52
+     * @var bool
53
+     */
54 54
     protected $empty = false;
55 55
     
56
-   /**
57
-    * @var array
58
-    */
56
+    /**
57
+     * @var array
58
+     */
59 59
     protected $knownUnits = array(
60 60
         '%' => true,
61 61
         'rem' => true,
@@ -95,21 +95,21 @@  discard block
 block discarded – undo
95 95
         return $this;
96 96
     }
97 97
     
98
-   /**
99
-    * Retrieves the raw, internal information array resulting
100
-    * from the parsing of the number.
101
-    *  
102
-    * @return array
103
-    */
98
+    /**
99
+     * Retrieves the raw, internal information array resulting
100
+     * from the parsing of the number.
101
+     *  
102
+     * @return array
103
+     */
104 104
     public function getRawInfo() : array
105 105
     {
106 106
         return $this->info;
107 107
     }
108 108
     
109
-   /**
110
-    * Whether the number was empty (null or empty string).
111
-    * @return boolean
112
-    */
109
+    /**
110
+     * Whether the number was empty (null or empty string).
111
+     * @return boolean
112
+     */
113 113
     public function isEmpty() : bool
114 114
     {
115 115
         return $this->empty;
@@ -532,12 +532,12 @@  discard block
 block discarded – undo
532 532
         return $cache[$key];
533 533
     }
534 534
     
535
-   /**
536
-    * Parses a string number notation with units included, e.g. 14px, 50%...
537
-    * 
538
-    * @param string $test
539
-    * @return array
540
-    */
535
+    /**
536
+     * Parses a string number notation with units included, e.g. 14px, 50%...
537
+     * 
538
+     * @param string $test
539
+     * @return array
540
+     */
541 541
     private function parseStringValue(string $test) : array
542 542
     {
543 543
         $number = null;
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
         return $this->filterInfo($result);
589 589
     }
590 590
     
591
-   /**
592
-    * Attempts to determine what kind of units are specified
593
-    * in the string. Returns NULL if none could be matched.
594
-    * 
595
-    * @param string $value
596
-    * @return array|NULL
597
-    */
591
+    /**
592
+     * Attempts to determine what kind of units are specified
593
+     * in the string. Returns NULL if none could be matched.
594
+     * 
595
+     * @param string $value
596
+     * @return array|NULL
597
+     */
598 598
     private function findUnits(string $value) : ?array
599 599
     {
600 600
         $vlength = strlen($value);
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
         return null;
623 623
     }
624 624
     
625
-   /**
626
-    * Creates the cache key for the specified value.
627
-    * 
628
-    * @param mixed $value
629
-    * @return string
630
-    */
625
+    /**
626
+     * Creates the cache key for the specified value.
627
+     * 
628
+     * @param mixed $value
629
+     * @return string
630
+     */
631 631
     private function createValueKey($value) : string
632 632
     {
633 633
         if(!is_string($value) && !is_numeric($value))
@@ -640,59 +640,59 @@  discard block
 block discarded – undo
640 640
     
641 641
     protected $postProcess = false;
642 642
     
643
-   /**
644
-    * Called if explicitly enabled: allows filtering the 
645
-    * number after the detection process has completed.
646
-    * 
647
-    * @param string|NULL $number The adjusted number
648
-    * @param string $originalString The original value before it was parsed
649
-    * @return mixed
650
-    */
643
+    /**
644
+     * Called if explicitly enabled: allows filtering the 
645
+     * number after the detection process has completed.
646
+     * 
647
+     * @param string|NULL $number The adjusted number
648
+     * @param string $originalString The original value before it was parsed
649
+     * @return mixed
650
+     */
651 651
     protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString)
652 652
     {
653 653
         return $number;
654 654
     }
655 655
     
656
-   /**
657
-    * Filters the value before it is parsed, but only if it is a string.
658
-    * 
659
-    * NOTE: This may be overwritten in a subclass, to allow custom filtering
660
-    * the the values. An example of a use case would be a preprocessor for
661
-    * variables in a templating system.
662
-    * 
663
-    * @param string $trimmedString The trimmed value.
664
-    * @param array $cache The internal values cache array.
665
-    * @param string $originalValue The original value that the NumberInfo was created for.
666
-    * @return string
667
-    * 
668
-    * @see NumberInfo::enablePostProcess()
669
-    */
656
+    /**
657
+     * Filters the value before it is parsed, but only if it is a string.
658
+     * 
659
+     * NOTE: This may be overwritten in a subclass, to allow custom filtering
660
+     * the the values. An example of a use case would be a preprocessor for
661
+     * variables in a templating system.
662
+     * 
663
+     * @param string $trimmedString The trimmed value.
664
+     * @param array $cache The internal values cache array.
665
+     * @param string $originalValue The original value that the NumberInfo was created for.
666
+     * @return string
667
+     * 
668
+     * @see NumberInfo::enablePostProcess()
669
+     */
670 670
     protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string
671 671
     {
672 672
         return str_replace(',', '.', $trimmedString);
673 673
     }
674 674
     
675
-   /**
676
-    * Enables the post processing so the postProcess method gets called.
677
-    * This should be called in the {@link NumberInfo::preProcess()}
678
-    * method as needed.
679
-    * 
680
-    * @return NumberInfo
681
-    * @see NumberInfo::postProcess()
682
-    */
675
+    /**
676
+     * Enables the post processing so the postProcess method gets called.
677
+     * This should be called in the {@link NumberInfo::preProcess()}
678
+     * method as needed.
679
+     * 
680
+     * @return NumberInfo
681
+     * @see NumberInfo::postProcess()
682
+     */
683 683
     protected function enablePostProcess() : NumberInfo
684 684
     {
685 685
         $this->postProcess = true;
686 686
         return $this;
687 687
     }
688 688
     
689
-   /**
690
-    * Filters the number info array to adjust the units
691
-    * and number according to the required rules.
692
-    * 
693
-    * @param array $info
694
-    * @return array
695
-    */
689
+    /**
690
+     * Filters the number info array to adjust the units
691
+     * and number according to the required rules.
692
+     * 
693
+     * @param array $info
694
+     * @return array
695
+     */
696 696
     protected function filterInfo(array $info) : array
697 697
     {
698 698
         $useUnits = 'px';
Please login to merge, or discard this patch.
src/RequestHelper/Response.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@
 block discarded – undo
142 142
     
143 143
     protected function getInfoKey(string $name) : string
144 144
     {
145
-        if(isset($this->info[$name])) {
145
+        if (isset($this->info[$name])) {
146 146
             return (string)$this->info[$name];
147 147
         }
148 148
         
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -19,51 +19,51 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class RequestHelper_Response
21 21
 {
22
-   /**
23
-    * @var RequestHelper
24
-    */
22
+    /**
23
+     * @var RequestHelper
24
+     */
25 25
     protected $request;
26 26
     
27
-   /**
28
-    * @var string
29
-    */
27
+    /**
28
+     * @var string
29
+     */
30 30
     protected $body = '';
31 31
     
32
-   /**
33
-    * @var array
34
-    */
32
+    /**
33
+     * @var array
34
+     */
35 35
     protected $info;
36 36
     
37
-   /**
38
-    * @var bool
39
-    */
37
+    /**
38
+     * @var bool
39
+     */
40 40
     protected $isError = false;
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $errorMessage = '';
46 46
     
47
-   /**
48
-    * @var integer
49
-    */
47
+    /**
48
+     * @var integer
49
+     */
50 50
     protected $errorCode = 0;
51 51
     
52
-   /**
53
-    * @param RequestHelper $helper
54
-    * @param array $info The CURL info array from curl_getinfo().
55
-    */
52
+    /**
53
+     * @param RequestHelper $helper
54
+     * @param array $info The CURL info array from curl_getinfo().
55
+     */
56 56
     public function __construct(RequestHelper $helper, array $info)
57 57
     {
58 58
         $this->request = $helper;
59 59
         $this->info = $info;
60 60
     }
61 61
     
62
-   /**
63
-    * Retrieves the request instance that initiated the request.
64
-    *  
65
-    * @return RequestHelper
66
-    */
62
+    /**
63
+     * Retrieves the request instance that initiated the request.
64
+     *  
65
+     * @return RequestHelper
66
+     */
67 67
     public function getRequest() : RequestHelper
68 68
     {
69 69
         return $this->request;
@@ -84,70 +84,70 @@  discard block
 block discarded – undo
84 84
         return $this;
85 85
     }
86 86
     
87
-   /**
88
-    * Whether an error occurred in the request.
89
-    * @return bool
90
-    */
87
+    /**
88
+     * Whether an error occurred in the request.
89
+     * @return bool
90
+     */
91 91
     public function isError() : bool
92 92
     {
93 93
         return $this->isError;
94 94
     }
95 95
     
96
-   /**
97
-    * Retrieves the native error message, if an error occurred.
98
-    * @return string
99
-    */
96
+    /**
97
+     * Retrieves the native error message, if an error occurred.
98
+     * @return string
99
+     */
100 100
     public function getErrorMessage() : string
101 101
     {
102 102
         return $this->errorMessage;
103 103
     }
104 104
     
105
-   /**
106
-    * Retrieves the native error code, if an error occurred.
107
-    * @return int
108
-    */
105
+    /**
106
+     * Retrieves the native error code, if an error occurred.
107
+     * @return int
108
+     */
109 109
     public function getErrorCode() : int
110 110
     {
111 111
         return $this->errorCode;
112 112
     }
113 113
     
114 114
     
115
-   /**
116
-    * Retrieves the full body of the request.
117
-    * 
118
-    * @return string
119
-    */
115
+    /**
116
+     * Retrieves the full body of the request.
117
+     * 
118
+     * @return string
119
+     */
120 120
     public function getRequestBody() : string
121 121
     {
122 122
         return $this->request->getBody();
123 123
     }
124 124
     
125
-   /**
126
-    * Retrieves the body of the response, if any.
127
-    * 
128
-    * @return string
129
-    */
125
+    /**
126
+     * Retrieves the body of the response, if any.
127
+     * 
128
+     * @return string
129
+     */
130 130
     public function getResponseBody() : string
131 131
     {
132 132
         return $this->body;
133 133
     }
134 134
     
135
-   /**
136
-    * The response HTTP code.
137
-    * 
138
-    * @return int The code, or 0 if none was sent (on error).
139
-    */
135
+    /**
136
+     * The response HTTP code.
137
+     * 
138
+     * @return int The code, or 0 if none was sent (on error).
139
+     */
140 140
     public function getCode() : int
141 141
     {
142 142
         return intval($this->getInfoKey('http_code'));
143 143
     }
144 144
     
145
-   /**
146
-    * Retrieves the actual headers that were sent in the request:
147
-    * one header by entry in the indexed array.
148
-    * 
149
-    * @return array
150
-    */
145
+    /**
146
+     * Retrieves the actual headers that were sent in the request:
147
+     * one header by entry in the indexed array.
148
+     * 
149
+     * @return array
150
+     */
151 151
     public function getHeaders() : array
152 152
     {
153 153
         return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header'));
Please login to merge, or discard this patch.
src/RequestHelper/Exception.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class RequestHelper_Exception extends BaseException
24 24
 {
25
-   /**
26
-    * @var RequestHelper_Response|NULL
27
-    */
25
+    /**
26
+     * @var RequestHelper_Response|NULL
27
+     */
28 28
     protected $response = null;
29 29
  
30 30
     public function setResponse(RequestHelper_Response $response)
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
         $this->response = $response;
33 33
     }
34 34
     
35
-   /**
36
-    * Retrieves the related response instance, if available.
37
-    * 
38
-    * @return RequestHelper_Response|NULL
39
-    */
35
+    /**
36
+     * Retrieves the related response instance, if available.
37
+     * 
38
+     * @return RequestHelper_Response|NULL
39
+     */
40 40
     public function getResponse() : ?RequestHelper_Response
41 41
     {
42 42
         return $this->response;
Please login to merge, or discard this patch.
src/URLInfo/Normalizer.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,23 +32,23 @@
 block discarded – undo
32 32
         $this->info = $info;
33 33
     }
34 34
     
35
-   /**
36
-    * Enables the authentication information in the URL,
37
-    * if a username and password are present.
38
-    * 
39
-    * @param bool $enable Whether to turn it on or off.
40
-    * @return URLInfo_Normalizer
41
-    */
35
+    /**
36
+     * Enables the authentication information in the URL,
37
+     * if a username and password are present.
38
+     * 
39
+     * @param bool $enable Whether to turn it on or off.
40
+     * @return URLInfo_Normalizer
41
+     */
42 42
     public function enableAuth(bool $enable=true) : URLInfo_Normalizer
43 43
     {
44 44
         $this->auth = $enable;
45 45
         return $this;
46 46
     }
47 47
     
48
-   /**
49
-    * Retrieves the normalized URL.
50
-    * @return string
51
-    */
48
+    /**
49
+     * Retrieves the normalized URL.
50
+     * @return string
51
+     */
52 52
     public function normalize() : string
53 53
     {
54 54
         $method = 'normalize_'.$this->info->getType();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     * @param bool $enable Whether to turn it on or off.
40 40
     * @return URLInfo_Normalizer
41 41
     */
42
-    public function enableAuth(bool $enable=true) : URLInfo_Normalizer
42
+    public function enableAuth(bool $enable = true) : URLInfo_Normalizer
43 43
     {
44 44
         $this->auth = $enable;
45 45
         return $this;
@@ -86,48 +86,48 @@  discard block
 block discarded – undo
86 86
     
87 87
     protected function renderAuth(string $normalized) : string
88 88
     {
89
-        if(!$this->info->hasUsername() || !$this->auth) {
89
+        if (!$this->info->hasUsername() || !$this->auth) {
90 90
             return $normalized;
91 91
         }
92 92
          
93
-        return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
93
+        return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
94 94
     }
95 95
     
96 96
     protected function renderPort(string $normalized) : string
97 97
     {
98
-        if(!$this->info->hasPort()) {
98
+        if (!$this->info->hasPort()) {
99 99
             return $normalized;
100 100
         }
101 101
         
102
-        return $normalized . ':'.$this->info->getPort();
102
+        return $normalized.':'.$this->info->getPort();
103 103
     }
104 104
     
105 105
     protected function renderPath(string $normalized) : string
106 106
     {
107
-        if(!$this->info->hasPath()) {
107
+        if (!$this->info->hasPath()) {
108 108
             return $normalized; 
109 109
         }
110 110
         
111
-        return $normalized . $this->info->getPath();
111
+        return $normalized.$this->info->getPath();
112 112
     }
113 113
     
114 114
     protected function renderParams(string $normalized) : string
115 115
     {
116 116
         $params = $this->info->getParams();
117 117
         
118
-        if(empty($params)) {
118
+        if (empty($params)) {
119 119
             return $normalized;
120 120
         }
121 121
         
122
-        return $normalized . '?'.http_build_query($params, null, '&', PHP_QUERY_RFC3986);
122
+        return $normalized.'?'.http_build_query($params, null, '&', PHP_QUERY_RFC3986);
123 123
     }
124 124
     
125 125
     protected function renderFragment(string $normalized) : string
126 126
     {
127
-        if(!$this->info->hasFragment()) {
127
+        if (!$this->info->hasFragment()) {
128 128
             return $normalized;
129 129
         }
130 130
         
131
-        return $normalized . '#'.$this->info->getFragment();
131
+        return $normalized.'#'.$this->info->getFragment();
132 132
     }
133 133
 }
Please login to merge, or discard this patch.
src/URLInfo.php 2 patches
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -39,42 +39,42 @@  discard block
 block discarded – undo
39 39
     const TYPE_PHONE = 'phone';
40 40
     const TYPE_URL = 'url';
41 41
     
42
-   /**
43
-    * The original URL that was passed to the constructor.
44
-    * @var string
45
-    */
42
+    /**
43
+     * The original URL that was passed to the constructor.
44
+     * @var string
45
+     */
46 46
     protected $rawURL;
47 47
 
48
-   /**
49
-    * @var array
50
-    */
48
+    /**
49
+     * @var array
50
+     */
51 51
     protected $info;
52 52
     
53
-   /**
54
-    * @var string[]
55
-    */
53
+    /**
54
+     * @var string[]
55
+     */
56 56
     protected $excludedParams = array();
57 57
     
58
-   /**
59
-    * @var bool
60
-    * @see URLInfo::setParamExclusion()
61
-    */
58
+    /**
59
+     * @var bool
60
+     * @see URLInfo::setParamExclusion()
61
+     */
62 62
     protected $paramExclusion = false;
63 63
     
64
-   /**
65
-    * @var array
66
-    * @see URLInfo::getTypeLabel()
67
-    */
64
+    /**
65
+     * @var array
66
+     * @see URLInfo::getTypeLabel()
67
+     */
68 68
     protected static $typeLabels;
69 69
     
70
-   /**
71
-    * @var bool
72
-    */
70
+    /**
71
+     * @var bool
72
+     */
73 73
     protected $highlightExcluded = false;
74 74
     
75
-   /**
76
-    * @var array
77
-    */
75
+    /**
76
+     * @var array
77
+     */
78 78
     protected $infoKeys = array(
79 79
         'scheme',
80 80
         'host',
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
         'fragment'
87 87
     );
88 88
     
89
-   /**
90
-    * @var string
91
-    */
89
+    /**
90
+     * @var string
91
+     */
92 92
     protected $url;
93 93
     
94
-   /**
95
-    * @var URLInfo_Parser
96
-    */
94
+    /**
95
+     * @var URLInfo_Parser
96
+     */
97 97
     protected $parser;
98 98
     
99
-   /**
100
-    * @var URLInfo_Normalizer
101
-    */
99
+    /**
100
+     * @var URLInfo_Normalizer
101
+     */
102 102
     protected $normalizer;
103 103
     
104 104
     public function __construct(string $url)
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
         $this->info = $this->parser->getInfo();
111 111
     }
112 112
     
113
-   /**
114
-    * Filters an URL: removes control characters and the
115
-    * like to have a clean URL to work with.
116
-    * 
117
-    * @param string $url
118
-    * @return string
119
-    */
113
+    /**
114
+     * Filters an URL: removes control characters and the
115
+     * like to have a clean URL to work with.
116
+     * 
117
+     * @param string $url
118
+     * @return string
119
+     */
120 120
     public static function filterURL(string $url)
121 121
     {
122 122
         return URLInfo_Filter::filter($url);
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
         return $this->info['type'] === self::TYPE_PHONE;
147 147
     }
148 148
     
149
-   /**
150
-    * Whether the URL is a regular URL, not one of the 
151
-    * other types like a phone number or email address.
152
-    * 
153
-    * @return bool
154
-    */
149
+    /**
150
+     * Whether the URL is a regular URL, not one of the 
151
+     * other types like a phone number or email address.
152
+     * 
153
+     * @return bool
154
+     */
155 155
     public function isURL() : bool
156 156
     {
157 157
         $host = $this->getHost();
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
         return $this->parser->isValid();
164 164
     }
165 165
     
166
-   /**
167
-    * Retrieves the host name, or an empty string if none is present.
168
-    * 
169
-    * @return string
170
-    */
166
+    /**
167
+     * Retrieves the host name, or an empty string if none is present.
168
+     * 
169
+     * @return string
170
+     */
171 171
     public function getHost() : string
172 172
     {
173 173
         return $this->getInfoKey('host');
174 174
     }
175 175
     
176
-   /**
177
-    * Retrieves the path, or an empty string if none is present.
178
-    * @return string
179
-    */
176
+    /**
177
+     * Retrieves the path, or an empty string if none is present.
178
+     * @return string
179
+     */
180 180
     public function getPath() : string
181 181
     {
182 182
         return $this->getInfoKey('path');
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
         return $this->getInfoKey('scheme');
193 193
     }
194 194
     
195
-   /**
196
-    * Retrieves the port specified in the URL, or -1 if none is preseent.
197
-    * @return int
198
-    */
195
+    /**
196
+     * Retrieves the port specified in the URL, or -1 if none is preseent.
197
+     * @return int
198
+     */
199 199
     public function getPort() : int
200 200
     {
201 201
         $port = $this->getInfoKey('port');
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
         return -1;
208 208
     }
209 209
     
210
-   /**
211
-    * Retrieves the raw query string, or an empty string if none is present.
212
-    * 
213
-    * @return string
214
-    * 
215
-    * @see URLInfo::getParams()
216
-    */
210
+    /**
211
+     * Retrieves the raw query string, or an empty string if none is present.
212
+     * 
213
+     * @return string
214
+     * 
215
+     * @see URLInfo::getParams()
216
+     */
217 217
     public function getQuery() : string
218 218
     {
219 219
         return $this->getInfoKey('query');
@@ -229,20 +229,20 @@  discard block
 block discarded – undo
229 229
         return $this->getInfoKey('pass');
230 230
     }
231 231
     
232
-   /**
233
-    * Whether the URL contains a port number.
234
-    * @return bool
235
-    */
232
+    /**
233
+     * Whether the URL contains a port number.
234
+     * @return bool
235
+     */
236 236
     public function hasPort() : bool
237 237
     {
238 238
         return $this->getPort() !== -1;
239 239
     }
240 240
     
241
-   /**
242
-    * Alias for the hasParams() method.
243
-    * @return bool
244
-    * @see URLInfo::hasParams()
245
-    */
241
+    /**
242
+     * Alias for the hasParams() method.
243
+     * @return bool
244
+     * @see URLInfo::hasParams()
245
+     */
246 246
     public function hasQuery() : bool
247 247
     {
248 248
         return $this->hasParams();
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
         return '';
288 288
     }
289 289
 
290
-   /**
291
-    * Retrieves a normalized URL: this ensures that all parameters
292
-    * in the URL are always in the same order.
293
-    * 
294
-    * @return string
295
-    */
290
+    /**
291
+     * Retrieves a normalized URL: this ensures that all parameters
292
+     * in the URL are always in the same order.
293
+     * 
294
+     * @return string
295
+     */
296 296
     public function getNormalized() : string
297 297
     {
298 298
         return $this->normalize(true);
299 299
     }
300 300
     
301
-   /**
302
-    * Like getNormalized(), but if a username and password are present
303
-    * in the URL, returns the URL without them.
304
-    * 
305
-    * @return string
306
-    */
301
+    /**
302
+     * Like getNormalized(), but if a username and password are present
303
+     * in the URL, returns the URL without them.
304
+     * 
305
+     * @return string
306
+     */
307 307
     public function getNormalizedWithoutAuth() : string
308 308
     {
309 309
         return $this->normalize(false);
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
         return $this->normalizer->normalize();
325 325
     }
326 326
     
327
-   /**
328
-    * Creates a hash of the URL, which can be used for comparisons.
329
-    * Since any parameters in the URL's query are sorted alphabetically,
330
-    * the same links with a different parameter order will have the 
331
-    * same hash.
332
-    * 
333
-    * @return string
334
-    */
327
+    /**
328
+     * Creates a hash of the URL, which can be used for comparisons.
329
+     * Since any parameters in the URL's query are sorted alphabetically,
330
+     * the same links with a different parameter order will have the 
331
+     * same hash.
332
+     * 
333
+     * @return string
334
+     */
335 335
     public function getHash()
336 336
     {
337 337
         return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized());
338 338
     }
339 339
 
340
-   /**
341
-    * Highlights the URL using HTML tags with specific highlighting
342
-    * class names.
343
-    * 
344
-    * @return string Will return an empty string if the URL is not valid.
345
-    */
340
+    /**
341
+     * Highlights the URL using HTML tags with specific highlighting
342
+     * class names.
343
+     * 
344
+     * @return string Will return an empty string if the URL is not valid.
345
+     */
346 346
     public function getHighlighted() : string
347 347
     {
348 348
         if(!$this->isValid()) {
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
         return count($params);
377 377
     }
378 378
     
379
-   /**
380
-    * Retrieves all parameters specified in the url,
381
-    * if any, as an associative array. 
382
-    * 
383
-    * NOTE: Ignores parameters that have been added
384
-    * to the excluded parameters list.
385
-    *
386
-    * @return array
387
-    */
379
+    /**
380
+     * Retrieves all parameters specified in the url,
381
+     * if any, as an associative array. 
382
+     * 
383
+     * NOTE: Ignores parameters that have been added
384
+     * to the excluded parameters list.
385
+     *
386
+     * @return array
387
+     */
388 388
     public function getParams() : array
389 389
     {
390 390
         if(!$this->paramExclusion || empty($this->excludedParams)) {
@@ -402,22 +402,22 @@  discard block
 block discarded – undo
402 402
         return $keep;
403 403
     }
404 404
     
405
-   /**
406
-    * Retrieves the names of all parameters present in the URL, if any.
407
-    * @return string[]
408
-    */
405
+    /**
406
+     * Retrieves the names of all parameters present in the URL, if any.
407
+     * @return string[]
408
+     */
409 409
     public function getParamNames() : array
410 410
     {
411 411
         $params = $this->getParams();
412 412
         return array_keys($params);
413 413
     }
414 414
     
415
-   /**
416
-    * Retrieves a specific parameter value from the URL.
417
-    * 
418
-    * @param string $name
419
-    * @return string The parameter value, or an empty string if it does not exist.
420
-    */
415
+    /**
416
+     * Retrieves a specific parameter value from the URL.
417
+     * 
418
+     * @param string $name
419
+     * @return string The parameter value, or an empty string if it does not exist.
420
+     */
421 421
     public function getParam(string $name) : string
422 422
     {
423 423
         if(isset($this->info['params'][$name])) {
@@ -427,16 +427,16 @@  discard block
 block discarded – undo
427 427
         return '';
428 428
     }
429 429
     
430
-   /**
431
-    * Excludes an URL parameter entirely if present:
432
-    * the parser will act as if the parameter was not
433
-    * even present in the source URL, effectively
434
-    * stripping it.
435
-    *
436
-    * @param string $name
437
-    * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
438
-    * @return URLInfo
439
-    */
430
+    /**
431
+     * Excludes an URL parameter entirely if present:
432
+     * the parser will act as if the parameter was not
433
+     * even present in the source URL, effectively
434
+     * stripping it.
435
+     *
436
+     * @param string $name
437
+     * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
438
+     * @return URLInfo
439
+     */
440 440
     public function excludeParam(string $name, string $reason) : URLInfo
441 441
     {
442 442
         if(!isset($this->excludedParams[$name]))
@@ -489,25 +489,25 @@  discard block
 block discarded – undo
489 489
         return self::$typeLabels[$this->getType()];
490 490
     }
491 491
 
492
-   /**
493
-    * Whether excluded parameters should be highlighted in
494
-    * a different color in the URL when using the
495
-    * {@link URLInfo::getHighlighted()} method.
496
-    *
497
-    * @param bool $highlight
498
-    * @return URLInfo
499
-    */
492
+    /**
493
+     * Whether excluded parameters should be highlighted in
494
+     * a different color in the URL when using the
495
+     * {@link URLInfo::getHighlighted()} method.
496
+     *
497
+     * @param bool $highlight
498
+     * @return URLInfo
499
+     */
500 500
     public function setHighlightExcluded(bool $highlight=true) : URLInfo
501 501
     {
502 502
         $this->highlightExcluded = $highlight;
503 503
         return $this;
504 504
     }
505 505
     
506
-   /**
507
-    * Returns an array with all relevant URL information.
508
-    * 
509
-    * @return array
510
-    */
506
+    /**
507
+     * Returns an array with all relevant URL information.
508
+     * 
509
+     * @return array
510
+     */
511 511
     public function toArray() : array
512 512
     {
513 513
         return array(
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
         return $this;
552 552
     }
553 553
     
554
-   /**
555
-    * Whether the parameter exclusion mode is enabled:
556
-    * In this case, if any parameters have been added to the
557
-    * exclusion list, all relevant methods will exclude these.
558
-    *
559
-    * @return bool
560
-    */
554
+    /**
555
+     * Whether the parameter exclusion mode is enabled:
556
+     * In this case, if any parameters have been added to the
557
+     * exclusion list, all relevant methods will exclude these.
558
+     *
559
+     * @return bool
560
+     */
561 561
     public function isParamExclusionEnabled() : bool
562 562
     {
563 563
         return $this->paramExclusion;
564 564
     }
565 565
     
566
-   /**
567
-    * Checks whether the link contains any parameters that
568
-    * are on the list of excluded parameters.
569
-    *
570
-    * @return bool
571
-    */
566
+    /**
567
+     * Checks whether the link contains any parameters that
568
+     * are on the list of excluded parameters.
569
+     *
570
+     * @return bool
571
+     */
572 572
     public function containsExcludedParams() : bool
573 573
     {
574 574
         if(empty($this->excludedParams)) {
@@ -636,16 +636,16 @@  discard block
 block discarded – undo
636 636
         return $this->highlightExcluded;
637 637
     }
638 638
     
639
-   /**
640
-    * Checks if the URL exists, i.e. can be connected to. Will return
641
-    * true if the returned HTTP status code is `200` or `302`.
642
-    * 
643
-    * NOTE: If the target URL requires HTTP authentication, the username
644
-    * and password should be integrated into the URL.
645
-    * 
646
-    * @return bool
647
-    * @throws BaseException
648
-    */
639
+    /**
640
+     * Checks if the URL exists, i.e. can be connected to. Will return
641
+     * true if the returned HTTP status code is `200` or `302`.
642
+     * 
643
+     * NOTE: If the target URL requires HTTP authentication, the username
644
+     * and password should be integrated into the URL.
645
+     * 
646
+     * @return bool
647
+     * @throws BaseException
648
+     */
649 649
     public function tryConnect(bool $verifySSL=true) : bool
650 650
     {
651 651
         requireCURL();
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $port = $this->getInfoKey('port');
202 202
         
203
-        if(!empty($port)) {
203
+        if (!empty($port)) {
204 204
             return (int)$port;
205 205
         }
206 206
         
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     
281 281
     protected function getInfoKey(string $name) : string
282 282
     {
283
-        if(isset($this->info[$name])) {
283
+        if (isset($this->info[$name])) {
284 284
             return (string)$this->info[$name];
285 285
         }
286 286
         
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
         return $this->normalize(false);
310 310
     }
311 311
     
312
-    protected function normalize(bool $auth=true) : string
312
+    protected function normalize(bool $auth = true) : string
313 313
     {
314
-        if(!$this->isValid()) {
314
+        if (!$this->isValid()) {
315 315
             return '';
316 316
         }
317 317
         
318
-        if(!isset($this->normalizer)) {
318
+        if (!isset($this->normalizer)) {
319 319
             $this->normalizer = new URLInfo_Normalizer($this);
320 320
         }
321 321
         
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     */
346 346
     public function getHighlighted() : string
347 347
     {
348
-        if(!$this->isValid()) {
348
+        if (!$this->isValid()) {
349 349
             return '';
350 350
         }
351 351
         
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
     */
388 388
     public function getParams() : array
389 389
     {
390
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
390
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
391 391
             return $this->info['params'];
392 392
         }
393 393
         
394 394
         $keep = array();
395
-        foreach($this->info['params'] as $name => $value) 
395
+        foreach ($this->info['params'] as $name => $value) 
396 396
         {
397
-            if(!isset($this->excludedParams[$name])) {
397
+            if (!isset($this->excludedParams[$name])) {
398 398
                 $keep[$name] = $value;
399 399
             }
400 400
         }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     */
421 421
     public function getParam(string $name) : string
422 422
     {
423
-        if(isset($this->info['params'][$name])) {
423
+        if (isset($this->info['params'][$name])) {
424 424
             return $this->info['params'][$name];
425 425
         }
426 426
         
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     */
440 440
     public function excludeParam(string $name, string $reason) : URLInfo
441 441
     {
442
-        if(!isset($this->excludedParams[$name]))
442
+        if (!isset($this->excludedParams[$name]))
443 443
         {
444 444
             $this->excludedParams[$name] = $reason;
445 445
             $this->setParamExclusion();
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     
466 466
     public function getTypeLabel() : string
467 467
     {
468
-        if(!isset(self::$typeLabels))
468
+        if (!isset(self::$typeLabels))
469 469
         {
470 470
             self::$typeLabels = array(
471 471
                 self::TYPE_EMAIL => t('Email'),
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         
478 478
         $type = $this->getType();
479 479
         
480
-        if(!isset(self::$typeLabels[$type]))
480
+        if (!isset(self::$typeLabels[$type]))
481 481
         {
482 482
             throw new BaseException(
483 483
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     * @param bool $highlight
498 498
     * @return URLInfo
499 499
     */
500
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
500
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
501 501
     {
502 502
         $this->highlightExcluded = $highlight;
503 503
         return $this;
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      * @see URLInfo::isParamExclusionEnabled()
546 546
      * @see URLInfo::setHighlightExcluded()
547 547
      */
548
-    public function setParamExclusion(bool $enabled=true) : URLInfo
548
+    public function setParamExclusion(bool $enabled = true) : URLInfo
549 549
     {
550 550
         $this->paramExclusion = $enabled;
551 551
         return $this;
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
     */
572 572
     public function containsExcludedParams() : bool
573 573
     {
574
-        if(empty($this->excludedParams)) {
574
+        if (empty($this->excludedParams)) {
575 575
             return false;
576 576
         }
577 577
         
578 578
         $names = array_keys($this->info['params']);
579
-        foreach($names as $name) {
580
-            if(isset($this->excludedParams[$name])) {
579
+        foreach ($names as $name) {
580
+            if (isset($this->excludedParams[$name])) {
581 581
                 return true;
582 582
             }
583 583
         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
     public function offsetSet($offset, $value) 
595 595
     {
596
-        if(in_array($offset, $this->infoKeys)) {
596
+        if (in_array($offset, $this->infoKeys)) {
597 597
             $this->info[$offset] = $value;
598 598
         }
599 599
     }
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
     
611 611
     public function offsetGet($offset) 
612 612
     {
613
-        if($offset === 'port') {
613
+        if ($offset === 'port') {
614 614
             return $this->getPort();
615 615
         }
616 616
         
617
-        if(in_array($offset, $this->infoKeys)) {
617
+        if (in_array($offset, $this->infoKeys)) {
618 618
             return $this->getInfoKey($offset);
619 619
         }
620 620
         
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
     * @return bool
647 647
     * @throws BaseException
648 648
     */
649
-    public function tryConnect(bool $verifySSL=true) : bool
649
+    public function tryConnect(bool $verifySSL = true) : bool
650 650
     {
651 651
         requireCURL();
652 652
         
653 653
         $ch = curl_init();
654
-        if(!is_resource($ch))
654
+        if (!is_resource($ch))
655 655
         {
656 656
             throw new BaseException(
657 657
                 'Could not initialize a new cURL instance.',
@@ -667,13 +667,13 @@  discard block
 block discarded – undo
667 667
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
668 668
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
669 669
         
670
-        if(!$verifySSL) 
670
+        if (!$verifySSL) 
671 671
         {
672 672
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
673 673
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
674 674
         }
675 675
         
676
-        if($this->hasUsername()) 
676
+        if ($this->hasUsername()) 
677 677
         {
678 678
             curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername());
679 679
             curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword());
Please login to merge, or discard this patch.