@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function detect() : bool |
| 13 | 13 | { |
| 14 | - if($this->getScheme() === 'tel') { |
|
| 14 | + if ($this->getScheme() === 'tel') { |
|
| 15 | 15 | $this->setTypePhone(); |
| 16 | 16 | return true; |
| 17 | 17 | } |
@@ -15,13 +15,13 @@ |
||
| 15 | 15 | // every link needs a host. This case can happen for ex, if |
| 16 | 16 | // the link starts with a typo with only one slash, like: |
| 17 | 17 | // "http:/hostname" |
| 18 | - if($this->hasHost() || $this->isSchemeLess()) { |
|
| 18 | + if ($this->hasHost() || $this->isSchemeLess()) { |
|
| 19 | 19 | return true; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $this->parser->setError( |
| 23 | 23 | URLInfo::ERROR_MISSING_HOST, |
| 24 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
| 24 | + t('Cannot determine the link\'s host name.').' '. |
|
| 25 | 25 | t('This usually happens when there\'s a typo somewhere.') |
| 26 | 26 | ); |
| 27 | 27 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function validate() : bool |
| 14 | 14 | { |
| 15 | - if($this->getType() !== URLInfo::TYPE_NONE) |
|
| 15 | + if ($this->getType() !== URLInfo::TYPE_NONE) |
|
| 16 | 16 | { |
| 17 | 17 | return true; |
| 18 | 18 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function validate() : bool |
| 14 | 14 | { |
| 15 | - if($this->hasScheme() || $this->isFragmentOnly()) { |
|
| 15 | + if ($this->hasScheme() || $this->isFragmentOnly()) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | public function validate() : bool |
| 15 | 15 | { |
| 16 | - if(!$this->hasScheme() || URISchemes::isValidSchemeName((string)$this->getScheme())) { |
|
| 16 | + if (!$this->hasScheme() || URISchemes::isValidSchemeName((string)$this->getScheme())) { |
|
| 17 | 17 | return true; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $this->parser->setError( |
| 23 | 23 | URLInfo::ERROR_INVALID_SCHEME, |
| 24 | - t('The scheme %1$s is not supported for links.', $this->getScheme()) . ' ' . |
|
| 24 | + t('The scheme %1$s is not supported for links.', $this->getScheme()).' '. |
|
| 25 | 25 | t('Valid schemes are: %1$s.', implode(', ', URISchemes::getSchemeNames())) |
| 26 | 26 | ); |
| 27 | 27 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function detectScheme(string $url) : ?string |
| 75 | 75 | { |
| 76 | - foreach(self::$schemes as $scheme) { |
|
| 77 | - if(stripos($url, $scheme) === 0) { |
|
| 76 | + foreach (self::$schemes as $scheme) { |
|
| 77 | + if (stripos($url, $scheme) === 0) { |
|
| 78 | 78 | return $scheme; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @var string[]|null |
| 87 | 87 | */ |
| 88 | - private static ?array $schemeNames = null; |
|
| 88 | + private static ? array $schemeNames = null; |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @return string[] |
| 92 | 92 | */ |
| 93 | 93 | public static function getSchemeNames() : array |
| 94 | 94 | { |
| 95 | - if(isset(self::$schemeNames)) { |
|
| 95 | + if (isset(self::$schemeNames)) { |
|
| 96 | 96 | return self::$schemeNames; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | self::$schemeNames = array(); |
| 100 | 100 | |
| 101 | - foreach(self::$schemes as $scheme) { |
|
| 101 | + foreach (self::$schemes as $scheme) { |
|
| 102 | 102 | self::$schemeNames[] = self::resolveSchemeName($scheme); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | self::requireValidScheme($scheme); |
| 133 | 133 | |
| 134 | - if(!in_array($scheme, self::$schemes, true)) |
|
| 134 | + if (!in_array($scheme, self::$schemes, true)) |
|
| 135 | 135 | { |
| 136 | 136 | self::$schemes[] = $scheme; |
| 137 | 137 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public static function requireValidScheme(string $scheme) : void |
| 143 | 143 | { |
| 144 | - if(strpos($scheme, ':')) |
|
| 144 | + if (strpos($scheme, ':')) |
|
| 145 | 145 | { |
| 146 | 146 | return; |
| 147 | 147 | } |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Whether to verify the host's SSL certificate, in |
|
| 46 | - * case of a https connection. |
|
| 47 | - * |
|
| 48 | - * @param bool $verifySSL |
|
| 49 | - * @return URIConnectionTester |
|
| 50 | - */ |
|
| 44 | + /** |
|
| 45 | + * Whether to verify the host's SSL certificate, in |
|
| 46 | + * case of a https connection. |
|
| 47 | + * |
|
| 48 | + * @param bool $verifySSL |
|
| 49 | + * @return URIConnectionTester |
|
| 50 | + */ |
|
| 51 | 51 | public function setVerifySSL(bool $verifySSL=true) : URIConnectionTester |
| 52 | 52 | { |
| 53 | 53 | $this->setOption('verify-ssl', $verifySSL); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | return $this->getIntOption('timeout'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Initializes the CURL instance. |
|
| 86 | - * |
|
| 87 | - * @throws BaseException |
|
| 88 | - * @return resource |
|
| 89 | - */ |
|
| 84 | + /** |
|
| 85 | + * Initializes the CURL instance. |
|
| 86 | + * |
|
| 87 | + * @throws BaseException |
|
| 88 | + * @return resource |
|
| 89 | + */ |
|
| 90 | 90 | private function initCURL() |
| 91 | 91 | { |
| 92 | 92 | $ch = curl_init(); |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | return $ch; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @param resource $ch |
|
| 108 | - */ |
|
| 106 | + /** |
|
| 107 | + * @param resource $ch |
|
| 108 | + */ |
|
| 109 | 109 | private function configureOptions($ch) : void |
| 110 | 110 | { |
| 111 | 111 | if($this->isVerboseModeEnabled()) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param bool $verifySSL |
| 49 | 49 | * @return URIConnectionTester |
| 50 | 50 | */ |
| 51 | - public function setVerifySSL(bool $verifySSL=true) : URIConnectionTester |
|
| 51 | + public function setVerifySSL(bool $verifySSL = true) : URIConnectionTester |
|
| 52 | 52 | { |
| 53 | 53 | $this->setOption('verify-ssl', $verifySSL); |
| 54 | 54 | return $this; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | return $this->getBoolOption('verify-ssl'); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function setVerboseMode(bool $enabled=true) : URIConnectionTester |
|
| 62 | + public function setVerboseMode(bool $enabled = true) : URIConnectionTester |
|
| 63 | 63 | { |
| 64 | 64 | $this->setOption('curl-verbose', $enabled); |
| 65 | 65 | return $this; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $ch = curl_init(); |
| 93 | 93 | |
| 94 | - if(!is_resource($ch)) |
|
| 94 | + if (!is_resource($ch)) |
|
| 95 | 95 | { |
| 96 | 96 | throw new URLException( |
| 97 | 97 | 'Could not initialize a new cURL instance.', |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | private function configureOptions($ch) : void |
| 110 | 110 | { |
| 111 | - if($this->isVerboseModeEnabled()) |
|
| 111 | + if ($this->isVerboseModeEnabled()) |
|
| 112 | 112 | { |
| 113 | 113 | curl_setopt($ch, CURLOPT_VERBOSE, true); |
| 114 | 114 | } |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->getTimeout()); |
| 119 | 119 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 120 | 120 | |
| 121 | - if(!$this->isVerifySSLEnabled()) |
|
| 121 | + if (!$this->isVerifySSLEnabled()) |
|
| 122 | 122 | { |
| 123 | 123 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 124 | 124 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if($this->url->hasUsername()) |
|
| 127 | + if ($this->url->hasUsername()) |
|
| 128 | 128 | { |
| 129 | 129 | curl_setopt($ch, CURLOPT_USERNAME, $this->url->getUsername()); |
| 130 | 130 | curl_setopt($ch, CURLOPT_PASSWORD, $this->url->getPassword()); |
@@ -28,23 +28,23 @@ |
||
| 28 | 28 | $this->info = $info; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Enables the authentication information in the URL, |
|
| 33 | - * if a username and password are present. |
|
| 34 | - * |
|
| 35 | - * @param bool $enable Whether to turn it on or off. |
|
| 36 | - * @return URINormalizer |
|
| 37 | - */ |
|
| 31 | + /** |
|
| 32 | + * Enables the authentication information in the URL, |
|
| 33 | + * if a username and password are present. |
|
| 34 | + * |
|
| 35 | + * @param bool $enable Whether to turn it on or off. |
|
| 36 | + * @return URINormalizer |
|
| 37 | + */ |
|
| 38 | 38 | public function enableAuth(bool $enable=true) : URINormalizer |
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Retrieves the normalized URL. |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 44 | + /** |
|
| 45 | + * Retrieves the normalized URL. |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | 48 | public function normalize() : string |
| 49 | 49 | { |
| 50 | 50 | $method = 'normalize_'.$this->info->getType(); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param bool $enable Whether to turn it on or off. |
| 36 | 36 | * @return URINormalizer |
| 37 | 37 | */ |
| 38 | - public function enableAuth(bool $enable=true) : URINormalizer |
|
| 38 | + public function enableAuth(bool $enable = true) : URINormalizer |
|
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | $scheme = $this->info->getScheme(); |
| 73 | 73 | $normalized = ''; |
| 74 | 74 | |
| 75 | - if(!empty($scheme)) |
|
| 75 | + if (!empty($scheme)) |
|
| 76 | 76 | { |
| 77 | - $normalized = $this->info->getScheme() . '://'; |
|
| 77 | + $normalized = $this->info->getScheme().'://'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $normalized = $this->renderAuth($normalized); |
@@ -89,48 +89,48 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | protected function renderAuth(string $normalized) : string |
| 91 | 91 | { |
| 92 | - if(!$this->auth || !$this->info->hasUsername()) { |
|
| 92 | + if (!$this->auth || !$this->info->hasUsername()) { |
|
| 93 | 93 | return $normalized; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 96 | + return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | protected function renderPort(string $normalized) : string |
| 100 | 100 | { |
| 101 | - if(!$this->info->hasPort()) { |
|
| 101 | + if (!$this->info->hasPort()) { |
|
| 102 | 102 | return $normalized; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - return $normalized . ':'.$this->info->getPort(); |
|
| 105 | + return $normalized.':'.$this->info->getPort(); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | protected function renderPath(string $normalized) : string |
| 109 | 109 | { |
| 110 | - if(!$this->info->hasPath()) { |
|
| 110 | + if (!$this->info->hasPath()) { |
|
| 111 | 111 | return $normalized; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return $normalized . $this->info->getPath(); |
|
| 114 | + return $normalized.$this->info->getPath(); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | protected function renderParams(string $normalized) : string |
| 118 | 118 | { |
| 119 | 119 | $params = $this->info->getParams(); |
| 120 | 120 | |
| 121 | - if(empty($params)) { |
|
| 121 | + if (empty($params)) { |
|
| 122 | 122 | return $normalized; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return $normalized . '?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 125 | + return $normalized.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | protected function renderFragment(string $normalized) : string |
| 129 | 129 | { |
| 130 | - if(!$this->info->hasFragment()) { |
|
| 130 | + if (!$this->info->hasFragment()) { |
|
| 131 | 131 | return $normalized; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return $normalized . '#'.$this->info->getFragment(); |
|
| 134 | + return $normalized.'#'.$this->info->getFragment(); |
|
| 135 | 135 | } |
| 136 | 136 | } |
@@ -155,13 +155,13 @@ |
||
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Fetches all parameters in the URL, regardless of |
|
| 160 | - * whether parameter exclusion is enabled, so they |
|
| 161 | - * can be highlighted is need be. |
|
| 162 | - * |
|
| 163 | - * @return array<string,string> |
|
| 164 | - */ |
|
| 158 | + /** |
|
| 159 | + * Fetches all parameters in the URL, regardless of |
|
| 160 | + * whether parameter exclusion is enabled, so they |
|
| 161 | + * can be highlighted is need be. |
|
| 162 | + * |
|
| 163 | + * @return array<string,string> |
|
| 164 | + */ |
|
| 165 | 165 | protected function resolveParams() : array |
| 166 | 166 | { |
| 167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | 'fragment' |
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | - foreach($parts as $part) |
|
| 77 | + foreach ($parts as $part) |
|
| 78 | 78 | { |
| 79 | 79 | $method = 'render_'.$part; |
| 80 | 80 | $result[] = (string)$this->$method(); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function render_scheme() : string |
| 87 | 87 | { |
| 88 | - if(!$this->info->hasScheme()) { |
|
| 88 | + if (!$this->info->hasScheme()) { |
|
| 89 | 89 | return ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | protected function render_username() : string |
| 102 | 102 | { |
| 103 | - if(!$this->info->hasUsername()) { |
|
| 103 | + if (!$this->info->hasUsername()) { |
|
| 104 | 104 | return ''; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | protected function render_host() : string |
| 118 | 118 | { |
| 119 | - if(!$this->info->hasHost()) { |
|
| 119 | + if (!$this->info->hasHost()) { |
|
| 120 | 120 | return ''; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | protected function render_port() : string |
| 130 | 130 | { |
| 131 | - if(!$this->info->hasPort()) { |
|
| 131 | + if (!$this->info->hasPort()) { |
|
| 132 | 132 | return ''; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | protected function render_path() : string |
| 143 | 143 | { |
| 144 | - if(!$this->info->hasPath()) { |
|
| 144 | + if (!$this->info->hasPath()) { |
|
| 145 | 145 | return ''; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
| 168 | 168 | |
| 169 | - if($previous) |
|
| 169 | + if ($previous) |
|
| 170 | 170 | { |
| 171 | 171 | $this->info->setParamExclusion(false); |
| 172 | 172 | } |
@@ -182,19 +182,19 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $params = $this->resolveParams(); |
| 184 | 184 | |
| 185 | - if(empty($params)) { |
|
| 185 | + if (empty($params)) { |
|
| 186 | 186 | return ''; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $tokens = array(); |
| 190 | 190 | $excluded = array(); |
| 191 | 191 | |
| 192 | - if($this->info->isParamExclusionEnabled()) |
|
| 192 | + if ($this->info->isParamExclusionEnabled()) |
|
| 193 | 193 | { |
| 194 | 194 | $excluded = $this->info->getExcludedParams(); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - foreach($params as $param => $value) |
|
| 197 | + foreach ($params as $param => $value) |
|
| 198 | 198 | { |
| 199 | 199 | // If the parameter is numeric, it will automatically |
| 200 | 200 | // be an integer, so we need the conversion here. |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $tag = $this->resolveTag($excluded, $param); |
| 217 | 217 | |
| 218 | - if(!empty($tag)) |
|
| 218 | + if (!empty($tag)) |
|
| 219 | 219 | { |
| 220 | 220 | $tokens[] = sprintf($tag, $parts); |
| 221 | 221 | } |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | protected function resolveTag(array $excluded, string $paramName) : string |
| 235 | 235 | { |
| 236 | 236 | // regular, non-excluded parameter |
| 237 | - if(!isset($excluded[$paramName])) |
|
| 237 | + if (!isset($excluded[$paramName])) |
|
| 238 | 238 | { |
| 239 | 239 | return '<span class="link-param">%s</span>'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // highlight excluded parameters is disabled, ignore this parameter |
| 243 | - if(!$this->info->isHighlightExcludeEnabled()) |
|
| 243 | + if (!$this->info->isHighlightExcludeEnabled()) |
|
| 244 | 244 | { |
| 245 | 245 | return ''; |
| 246 | 246 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | protected function render_fragment() : string |
| 258 | 258 | { |
| 259 | - if(!$this->info->hasFragment()) { |
|
| 259 | + if (!$this->info->hasFragment()) { |
|
| 260 | 260 | return ''; |
| 261 | 261 | } |
| 262 | 262 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | { |
| 272 | 272 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 273 | 273 | |
| 274 | - if($cssFolder === false) { |
|
| 274 | + if ($cssFolder === false) { |
|
| 275 | 275 | throw new URLException( |
| 276 | 276 | 'Cannot find package CSS folder.', |
| 277 | 277 | null, |