@@ -21,7 +21,7 @@ |
||
21 | 21 | class InternetDomainParser |
22 | 22 | { |
23 | 23 | // todo inject/config ? |
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 | /** |
27 | 27 | * https://www.google.fr => google.fr |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46) |
62 | 62 | // checkdnsrr($string, "A") // check DNS record |
63 | 63 | if (!self::isHttpURL($url)) { |
64 | - throw new DomainException('URL not compatible : ' . $url); |
|
64 | + throw new DomainException('URL not compatible : '.$url); |
|
65 | 65 | } |
66 | 66 | $response = $this->client->get($url); |
67 | 67 | |
68 | 68 | if (200 !== $response->getStatusCode()) { |
69 | - echo 'HTTP error ' . $response->getStatusCode(); |
|
69 | + echo 'HTTP error '.$response->getStatusCode(); |
|
70 | 70 | if ($this->log !== null) { |
71 | - $this->log->error('HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
71 | + $this->log->error('HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return null; |
75 | 75 | } |
76 | 76 | |
77 | - $html = (string)$response->getBody()->getContents() ?? ''; |
|
77 | + $html = (string) $response->getBody()->getContents() ?? ''; |
|
78 | 78 | |
79 | 79 | return ($normalized) ? $this->normalizeHtml($html, $url) : $html; |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function isHttpURL(string $url): bool |
87 | 87 | { |
88 | - return (bool)preg_match('#^https?://[^ ]+$#i', $url); |
|
88 | + return (bool) preg_match('#^https?://[^ ]+$#i', $url); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $charset = $this->extractCharset($html) ?? 'WINDOWS-1252'; |
113 | 113 | |
114 | 114 | if (empty($charset)) { |
115 | - throw new DomainException('normalized html error and no charset found : ' . $url); |
|
115 | + throw new DomainException('normalized html error and no charset found : '.$url); |
|
116 | 116 | } |
117 | 117 | try { |
118 | 118 | $html2 = iconv($charset, 'UTF-8//TRANSLIT', $html); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return ''; |
122 | 122 | } |
123 | 123 | } catch (Throwable $e) { |
124 | - throw new DomainException("error converting : $charset to UTF-8" . $url, $e->getCode(), $e); |
|
124 | + throw new DomainException("error converting : $charset to UTF-8".$url, $e->getCode(), $e); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $html2; |