@@ -56,26 +56,26 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $normalized = $this->info->getScheme().'://'; |
| 58 | 58 | |
| 59 | - if($this->info->hasUsername()) { |
|
| 59 | + if ($this->info->hasUsername()) { |
|
| 60 | 60 | $normalized .= urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $normalized .= $this->info->getHost(); |
| 64 | 64 | |
| 65 | - if($this->info->hasPort()) { |
|
| 65 | + if ($this->info->hasPort()) { |
|
| 66 | 66 | $normalized .= ':'.$this->info->getPort(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if($this->info->hasPath()) { |
|
| 69 | + if ($this->info->hasPath()) { |
|
| 70 | 70 | $normalized .= $this->info->getPath(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $params = $this->info->getParams(); |
| 74 | - if(!empty($params)) { |
|
| 74 | + if (!empty($params)) { |
|
| 75 | 75 | $normalized .= '?'.http_build_query($params); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if($this->info->hasFragment()) { |
|
| 78 | + if ($this->info->hasFragment()) { |
|
| 79 | 79 | $normalized .= '#'.$this->info->getFragment(); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -59,7 +59,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function filterParsed() |
| 186 | 186 | { |
| 187 | - foreach($this->info as $key => $val) |
|
| 187 | + foreach ($this->info as $key => $val) |
|
| 188 | 188 | { |
| 189 | - if(is_string($val)) { |
|
| 189 | + if (is_string($val)) { |
|
| 190 | 190 | $this->info[$key] = trim($val); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -194,23 +194,23 @@ discard block |
||
| 194 | 194 | $this->info['params'] = array(); |
| 195 | 195 | $this->info['type'] = URLInfo::TYPE_URL; |
| 196 | 196 | |
| 197 | - if(isset($this->info['user'])) { |
|
| 197 | + if (isset($this->info['user'])) { |
|
| 198 | 198 | $this->info['user'] = urldecode($this->info['user']); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if(isset($this->info['pass'])) { |
|
| 201 | + if (isset($this->info['pass'])) { |
|
| 202 | 202 | $this->info['pass'] = urldecode($this->info['pass']); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if(isset($this->info['host'])) { |
|
| 205 | + if (isset($this->info['host'])) { |
|
| 206 | 206 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if(isset($this->info['path'])) { |
|
| 209 | + if (isset($this->info['path'])) { |
|
| 210 | 210 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if(isset($this->info['query']) && !empty($this->info['query'])) |
|
| 213 | + if (isset($this->info['query']) && !empty($this->info['query'])) |
|
| 214 | 214 | { |
| 215 | 215 | $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
| 216 | 216 | ksort($this->info['params']); |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | protected function detectType_email() : bool |
| 221 | 221 | { |
| 222 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 222 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 223 | 223 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
| 224 | 224 | return true; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 227 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 228 | 228 | { |
| 229 | 229 | $this->info['scheme'] = 'mailto'; |
| 230 | 230 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | protected function detectType_fragmentLink() : bool |
| 238 | 238 | { |
| 239 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 239 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 240 | 240 | $this->info['type'] = URLInfo::TYPE_FRAGMENT; |
| 241 | 241 | return true; |
| 242 | 242 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | protected function detectType_phoneLink() : bool |
| 248 | 248 | { |
| 249 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 249 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 250 | 250 | $this->info['type'] = URLInfo::TYPE_PHONE; |
| 251 | 251 | return true; |
| 252 | 252 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function getErrorMessage() : string |
| 273 | 273 | { |
| 274 | - if(isset($this->error)) { |
|
| 274 | + if (isset($this->error)) { |
|
| 275 | 275 | return $this->error['message']; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | public function getErrorCode() : int |
| 282 | 282 | { |
| 283 | - if(isset($this->error)) { |
|
| 283 | + if (isset($this->error)) { |
|
| 284 | 284 | return $this->error['code']; |
| 285 | 285 | } |
| 286 | 286 | |