@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class InternetDomainParser implements InternetDomainParserInterface |
| 23 | 23 | { |
| 24 | - private const PATH_CACHE_PUBLIC_SUFFIX_LIST = __DIR__ . '/resources/public_suffix_list.dat'; |
|
| 24 | + private const PATH_CACHE_PUBLIC_SUFFIX_LIST = __DIR__.'/resources/public_suffix_list.dat'; |
|
| 25 | 25 | |
| 26 | 26 | private readonly Rules $rules; |
| 27 | 27 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public static function extractSubdomainString(string $httpURL): string |
| 56 | 56 | { |
| 57 | 57 | if (!HttpUtil::isHttpURL($httpURL)) { |
| 58 | - throw new Exception('string is not an URL ' . $httpURL); |
|
| 58 | + throw new Exception('string is not an URL '.$httpURL); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return parse_url($httpURL, PHP_URL_HOST); |
@@ -31,11 +31,11 @@ |
||
| 31 | 31 | ?LoggerInterface $logger = null): ExternPage |
| 32 | 32 | { |
| 33 | 33 | if (!HttpUtil::isHttpURL($url)) { |
| 34 | - throw new Exception('string is not an URL ' . $url); |
|
| 34 | + throw new Exception('string is not an URL '.$url); |
|
| 35 | 35 | } |
| 36 | 36 | $html = $httpClient->getHTML($url, true); |
| 37 | 37 | if (empty($html)) { |
| 38 | - throw new DomainException('No HTML from requested URL ' . $url); |
|
| 38 | + throw new DomainException('No HTML from requested URL '.$url); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return new ExternPage($url, $html, new TagParser(), $domainParser, $logger); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | ) |
| 55 | 55 | { |
| 56 | 56 | if (!HttpUtil::isHttpURL($url)) { |
| 57 | - throw new Exception('string is not an URL ' . $url); |
|
| 57 | + throw new Exception('string is not an URL '.$url); |
|
| 58 | 58 | } |
| 59 | 59 | $this->url = $url; |
| 60 | 60 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | try { |
| 172 | 172 | if (!HttpUtil::isHttpURL($this->url)) { |
| 173 | - throw new Exception('string is not an URL ' . $this->url); |
|
| 173 | + throw new Exception('string is not an URL '.$this->url); |
|
| 174 | 174 | } |
| 175 | 175 | if (!$this->domainParser instanceof InternetDomainParserInterface) { |
| 176 | 176 | $this->log->notice('InternetDomainParser is not set'); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | return $this->domainParser->getRegistrableDomainFromURL($this->url); |
| 182 | 182 | } catch (Exception $e) { |
| 183 | 183 | if ($this->log !== null) { |
| 184 | - $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL ' . $this->url); |
|
| 184 | + $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL '.$this->url); |
|
| 185 | 185 | } |
| 186 | 186 | throw new Exception('InternetDomainParser->getRegistrableDomainFromURL NULL', $e->getCode(), $e); |
| 187 | 187 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $this->url = $url; |
| 50 | 50 | $this->registrableDomain = null; |
| 51 | 51 | if (!HttpUtil::isHttpURL($url)) { |
| 52 | - $this->log->debug('Skip : not a valid URL : ' . $url); |
|
| 52 | + $this->log->debug('Skip : not a valid URL : '.$url); |
|
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | if (!HttpUtil::isHttpURL($url)) { |
| 60 | - throw new Exception('string is not an URL ' . $url); |
|
| 60 | + throw new Exception('string is not an URL '.$url); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $this->findRegistrableDomain(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | try { |
| 80 | 80 | $this->registrableDomain = $this->internetDomainParser->getRegistrableDomainFromURL($this->url); |
| 81 | 81 | } catch (Exception) { |
| 82 | - $this->log->warning('Skip : not a valid URL : ' . $this->url); |
|
| 82 | + $this->log->warning('Skip : not a valid URL : '.$this->url); |
|
| 83 | 83 | return null; |
| 84 | 84 | } |
| 85 | 85 | return $this->registrableDomain; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function hasForbiddenFilenameExtension(): bool |
| 94 | 94 | { |
| 95 | - return (bool)preg_match( |
|
| 95 | + return (bool) preg_match( |
|
| 96 | 96 | '#\.(pdf|jpg|jpeg|gif|png|webp|xls|xlsx|xlr|xml|xlt|txt|csv|js|docx|exe|gz|zip|ini|movie|mp3|mp4|ogg|raw|rss|tar|tgz|wma)$#i', |
| 97 | 97 | $this->url |
| 98 | 98 | ); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public static function isHttpURL(string $url): bool |
| 24 | 24 | { |
| 25 | - return (bool)preg_match('#^https?://[^ ]+$#i', $url); |
|
| 25 | + return (bool) preg_match('#^https?://[^ ]+$#i', $url); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -43,20 +43,20 @@ discard block |
||
| 43 | 43 | $charset = self::extractCharset($html) ?? 'WINDOWS-1252'; |
| 44 | 44 | |
| 45 | 45 | if (empty($charset)) { |
| 46 | - throw new DomainException('normalized html error and no charset found : ' . $url); |
|
| 46 | + throw new DomainException('normalized html error and no charset found : '.$url); |
|
| 47 | 47 | } |
| 48 | 48 | try { |
| 49 | 49 | $html2 = iconv($charset, 'UTF-8//TRANSLIT', $html); |
| 50 | 50 | // PHP Notice: iconv(): Detected an illegal character in input string on line 107 |
| 51 | 51 | if (false === $html2) { |
| 52 | - throw new DomainException("error iconv : $charset to UTF-8 on " . $url); |
|
| 52 | + throw new DomainException("error iconv : $charset to UTF-8 on ".$url); |
|
| 53 | 53 | } |
| 54 | 54 | $html2 = Normalizer::normalize($html2); |
| 55 | 55 | if (!is_string($html2)) { |
| 56 | - throw new DomainException("error normalizer : $charset to UTF-8 on " . $url); |
|
| 56 | + throw new DomainException("error normalizer : $charset to UTF-8 on ".$url); |
|
| 57 | 57 | } |
| 58 | 58 | } catch (Throwable $e) { |
| 59 | - throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e); |
|
| 59 | + throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $html2; |
@@ -57,13 +57,13 @@ |
||
| 57 | 57 | // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46) |
| 58 | 58 | // checkdnsrr($string, "A") // check DNS record |
| 59 | 59 | if (!HttpUtil::isHttpURL($url)) { |
| 60 | - throw new DomainException('URL not compatible : ' . $url); |
|
| 60 | + throw new DomainException('URL not compatible : '.$url); |
|
| 61 | 61 | } |
| 62 | 62 | $response = $this->client->get($url); |
| 63 | 63 | |
| 64 | 64 | if (200 !== $response->getStatusCode()) { |
| 65 | - echo 'HTTP error ' . $response->getStatusCode(); |
|
| 66 | - $this->log->error('HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 65 | + echo 'HTTP error '.$response->getStatusCode(); |
|
| 66 | + $this->log->error('HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 67 | 67 | |
| 68 | 68 | return null; |
| 69 | 69 | } |