Passed
Push — master ( 2508f8...8e3f03 )
by Sebastian
02:23
created
src/URLInfo/Parser.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class URLInfo_Parser
22 22
 {
23
-   /**
24
-    * @var string
25
-    */
23
+    /**
24
+     * @var string
25
+     */
26 26
     protected $url;
27 27
     
28
-   /**
29
-    * @var bool
30
-    */
28
+    /**
29
+     * @var bool
30
+     */
31 31
     protected $isValid = false;
32 32
     
33
-   /**
34
-    * @var array
35
-    */
33
+    /**
34
+     * @var array
35
+     */
36 36
     protected $info;
37 37
     
38
-   /**
39
-    * @var array|NULL
40
-    */
38
+    /**
39
+     * @var array|NULL
40
+     */
41 41
     protected $error;
42 42
     
43 43
     /**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
         return false;
178 178
     }
179 179
 
180
-   /**
181
-    * Goes through all information in the parse_url result
182
-    * array, and attempts to fix any user errors in formatting
183
-    * that can be recovered from, mostly regarding stray spaces.
184
-    */
180
+    /**
181
+     * Goes through all information in the parse_url result
182
+     * array, and attempts to fix any user errors in formatting
183
+     * that can be recovered from, mostly regarding stray spaces.
184
+     */
185 185
     protected function filterParsed()
186 186
     {
187 187
         $this->info['params'] = array();
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         
60 60
         $this->parse();
61 61
         
62
-        if(!$this->detectType()) {
62
+        if (!$this->detectType()) {
63 63
             $this->validate();
64 64
         }
65 65
     }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
             'phoneLink'
94 94
         );
95 95
         
96
-        foreach($types as $type)
96
+        foreach ($types as $type)
97 97
         {
98 98
             $method = 'detectType_'.$type;
99 99
             
100
-            if($this->$method() === true) 
100
+            if ($this->$method() === true) 
101 101
             {
102 102
                 $this->isValid = true;
103 103
                 return true;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
             'hostIsPresent'
116 116
         );
117 117
         
118
-        foreach($validations as $validation) 
118
+        foreach ($validations as $validation) 
119 119
         {
120 120
             $method = 'validate_'.$validation;
121 121
             
122
-            if($this->$method() !== true) {
122
+            if ($this->$method() !== true) {
123 123
                 return;
124 124
             }
125 125
         }
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
         // every link needs a host. This case can happen for ex, if
133 133
         // the link starts with a typo with only one slash, like:
134 134
         // "http:/hostname"
135
-        if(isset($this->info['host'])) {
135
+        if (isset($this->info['host'])) {
136 136
             return true;
137 137
         }
138 138
         
139 139
         $this->setError(
140 140
             URLInfo::ERROR_MISSING_HOST,
141
-            t('Cannot determine the link\'s host name.') . ' ' .
141
+            t('Cannot determine the link\'s host name.').' '.
142 142
             t('This usually happens when there\'s a typo somewhere.')
143 143
         );
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     
148 148
     protected function validate_schemeIsSet() : bool
149 149
     {
150
-        if(isset($this->info['scheme'])) {
150
+        if (isset($this->info['scheme'])) {
151 151
             return true;
152 152
         }
153 153
         
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
     
165 165
     protected function validate_schemeIsKnown() : bool
166 166
     {
167
-        if(in_array($this->info['scheme'], $this->knownSchemes)) {
167
+        if (in_array($this->info['scheme'], $this->knownSchemes)) {
168 168
             return true;
169 169
         }
170 170
         
171 171
         $this->setError(
172 172
             URLInfo::ERROR_INVALID_SCHEME,
173
-            t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' .
173
+            t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '.
174 174
             t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes))
175 175
         );
176 176
 
@@ -187,23 +187,23 @@  discard block
 block discarded – undo
187 187
         $this->info['params'] = array();
188 188
         $this->info['type'] = URLInfo::TYPE_URL;
189 189
         
190
-        if(isset($this->info['user'])) {
190
+        if (isset($this->info['user'])) {
191 191
             $this->info['user'] = urldecode($this->info['user']);
192 192
         }
193 193
 
194
-        if(isset($this->info['pass'])) {
194
+        if (isset($this->info['pass'])) {
195 195
             $this->info['pass'] = urldecode($this->info['pass']);
196 196
         }
197 197
         
198
-        if(isset($this->info['host'])) {
198
+        if (isset($this->info['host'])) {
199 199
             $this->info['host'] = str_replace(' ', '', $this->info['host']);
200 200
         }
201 201
         
202
-        if(isset($this->info['path'])) {
202
+        if (isset($this->info['path'])) {
203 203
             $this->info['path'] = str_replace(' ', '', $this->info['path']);
204 204
         }
205 205
         
206
-        if(isset($this->info['query']) && !empty($this->info['query']))
206
+        if (isset($this->info['query']) && !empty($this->info['query']))
207 207
         {
208 208
             $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']);
209 209
             ksort($this->info['params']);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
     
213 213
     protected function detectType_email() : bool
214 214
     {
215
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
215
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
216 216
             $this->info['type'] = URLInfo::TYPE_EMAIL;
217 217
             return true;
218 218
         }
219 219
         
220
-        if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
220
+        if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
221 221
         {
222 222
             $this->info['scheme'] = 'mailto';
223 223
             $this->info['type'] = URLInfo::TYPE_EMAIL;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     
230 230
     protected function detectType_fragmentLink() : bool
231 231
     {
232
-        if(isset($this->info['fragment']) && !isset($this->info['scheme'])) {
232
+        if (isset($this->info['fragment']) && !isset($this->info['scheme'])) {
233 233
             $this->info['type'] = URLInfo::TYPE_FRAGMENT;
234 234
             return true;
235 235
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     
240 240
     protected function detectType_phoneLink() : bool
241 241
     {
242
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
242
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
243 243
             $this->info['type'] = URLInfo::TYPE_PHONE;
244 244
             return true;
245 245
         }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
     public function getErrorMessage() : string
266 266
     {
267
-        if(isset($this->error)) {
267
+        if (isset($this->error)) {
268 268
             return $this->error['message'];
269 269
         }
270 270
         
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     
274 274
     public function getErrorCode() : int
275 275
     {
276
-        if(isset($this->error)) {
276
+        if (isset($this->error)) {
277 277
             return $this->error['code'];
278 278
         }
279 279
         
Please login to merge, or discard this patch.