@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use Mediawiki\Api\MediawikiFactory; |
| 17 | 17 | use Normalizer; |
| 18 | 18 | |
| 19 | -include __DIR__ . '/../myBootstrap.php'; |
|
| 19 | +include __DIR__.'/../myBootstrap.php'; |
|
| 20 | 20 | |
| 21 | 21 | $process = new Monitor(); |
| 22 | 22 | $process->run(); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | [ |
| 98 | 98 | 'page' => $title ?? '', |
| 99 | 99 | 'verify' => date("Y-m-d H:i:s"), |
| 100 | - 'altered' => (int)$stat, |
|
| 100 | + 'altered' => (int) $stat, |
|
| 101 | 101 | ] |
| 102 | 102 | ); |
| 103 | 103 | } |
@@ -147,6 +147,6 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - return (int)round(($count - $found) / count($data) * 100); |
|
| 150 | + return (int) round(($count - $found) / count($data) * 100); |
|
| 151 | 151 | } |
| 152 | 152 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | if ( |
| 37 | 37 | !empty($robots) |
| 38 | 38 | && ( |
| 39 | - stripos((string)$robots, 'noindex') !== false |
|
| 40 | - || stripos((string)$robots, 'none') !== false |
|
| 39 | + stripos((string) $robots, 'noindex') !== false |
|
| 40 | + || stripos((string) $robots, 'none') !== false |
|
| 41 | 41 | ) |
| 42 | 42 | ) { |
| 43 | - $this->log->notice('robots NOINDEX : ' . $this->url); |
|
| 43 | + $this->log->notice('robots NOINDEX : '.$this->url); |
|
| 44 | 44 | |
| 45 | 45 | if (empty($this->pageData['meta']['prettyDomainName'])) { |
| 46 | - $this->log->warning('No prettyDomainName for ' . $this->url); |
|
| 46 | + $this->log->warning('No prettyDomainName for '.$this->url); |
|
| 47 | 47 | |
| 48 | 48 | return true; |
| 49 | 49 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | protected function isNoIndexDomainWhitelisted(?string $prettyDomain): bool |
| 58 | 58 | { |
| 59 | 59 | if (in_array($prettyDomain ?? '', $this->noindexWhitelist)) { |
| 60 | - $this->log->notice('ROBOT_NOINDEX_WHITELIST ' . $prettyDomain); |
|
| 60 | + $this->log->notice('ROBOT_NOINDEX_WHITELIST '.$prettyDomain); |
|
| 61 | 61 | |
| 62 | 62 | return true; |
| 63 | 63 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $this->xml = $xml; |
| 38 | 38 | |
| 39 | 39 | // skip multi-records |
| 40 | - $nbResults = (int)$xml->xpath('//srw:numberOfRecords[1]')[0] ?? 0; |
|
| 40 | + $nbResults = (int) $xml->xpath('//srw:numberOfRecords[1]')[0] ?? 0; |
|
| 41 | 41 | if (1 !== $nbResults) { |
| 42 | 42 | return []; |
| 43 | 43 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $res = []; |
| 122 | 122 | foreach ($elements as $element) { |
| 123 | 123 | if (isset($element) && $element instanceof SimpleXMLElement) { |
| 124 | - $res[] = (string)$element; |
|
| 124 | + $res[] = (string) $element; |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $raw = $this->xpath2string('//mxc:datafield[@tag="215"]/mxc:subfield[@code="a"]'); |
| 187 | 187 | if (!empty($raw) && preg_match('#(\d{2,}) p\.#', $raw, $matches) > 0) { |
| 188 | - return (string)$matches[1]; |
|
| 188 | + return (string) $matches[1]; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return null; |
@@ -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); |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | public function fromURL(string $url, InternetDomainParserInterface $domainParser): ExternPage |
| 31 | 31 | { |
| 32 | 32 | if (!HttpUtil::isHttpURL($url)) { |
| 33 | - throw new Exception('string is not an URL ' . $url); |
|
| 33 | + throw new Exception('string is not an URL '.$url); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $html = $this->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, $this->log); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46) |
| 55 | 55 | // checkdnsrr($string, "A") // check DNS record |
| 56 | 56 | if (!HttpUtil::isHttpURL($url)) { |
| 57 | - throw new DomainException('URL not compatible : ' . $url); |
|
| 57 | + throw new DomainException('URL not compatible : '.$url); |
|
| 58 | 58 | } |
| 59 | 59 | $response = $this->client->get($url, [ |
| 60 | 60 | 'timeout' => 20, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ]); |
| 66 | 66 | |
| 67 | 67 | if (200 !== $response->getStatusCode()) { |
| 68 | - $this->log->error('[z49] HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 68 | + $this->log->error('[z49] HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 69 | 69 | |
| 70 | 70 | return null; |
| 71 | 71 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | return null; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function get(string|UriInterface $uri, array $options = []): ResponseInterface |
|
| 89 | + public function get(string | UriInterface $uri, array $options = []): ResponseInterface |
|
| 90 | 90 | { |
| 91 | 91 | if (isset($options['allow_redirects']) && $options['allow_redirects'] !== false) { |
| 92 | 92 | $this->maxRedirects = self::DEFAULT_MAX_REDIRECTS; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * todo : add redirect http referer |
| 100 | 100 | */ |
| 101 | - private function getRecursive(UriInterface|string $uri, array $options, int $loop = 0): ResponseInterface |
|
| 101 | + private function getRecursive(UriInterface | string $uri, array $options, int $loop = 0): ResponseInterface |
|
| 102 | 102 | { |
| 103 | 103 | $response = $this->client->get($uri, $options); |
| 104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if ($response->getStatusCode() >= 300 && $response->getStatusCode() < 400) { |
| 107 | 107 | $redirectUri = $response->getHeader('location')[0] ?? null; |
| 108 | 108 | if ($loop >= $this->maxRedirects || !$redirectUri) { |
| 109 | - throw new Exception('TorClientAdapter::get Error too many redirects ' . $response->getStatusCode()); |
|
| 109 | + throw new Exception('TorClientAdapter::get Error too many redirects '.$response->getStatusCode()); |
|
| 110 | 110 | } |
| 111 | 111 | $loop++; |
| 112 | 112 | return $this->getRecursive($redirectUri, $options, $loop); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | // Error 4xx 5xx |
| 116 | 116 | if ($response->getStatusCode() >= 400) { |
| 117 | - throw new Exception($response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 117 | + throw new Exception($response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $response; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function get(string|UriInterface $uri, array $options = []): ResponseInterface |
|
| 43 | + public function get(string | UriInterface $uri, array $options = []): ResponseInterface |
|
| 44 | 44 | { |
| 45 | 45 | return $this->client->get($uri, $options); |
| 46 | 46 | } |
@@ -14,6 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | interface HttpClientInterface |
| 16 | 16 | { |
| 17 | - public function get(string|UriInterface $uri, array $options = []): ResponseInterface; |
|
| 17 | + public function get(string | UriInterface $uri, array $options = []): ResponseInterface; |
|
| 18 | 18 | public function request($method, $uri, array $options = []): ResponseInterface; |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -48,16 +48,16 @@ discard block |
||
| 48 | 48 | return new WebarchiveDTO( |
| 49 | 49 | self::ARCHIVER_NAME, |
| 50 | 50 | $url, |
| 51 | - (string)$archiveData['longformurl'], |
|
| 51 | + (string) $archiveData['longformurl'], |
|
| 52 | 52 | $archiveData['timestamp'] |
| 53 | - ? DateTimeImmutable::createFromFormat('U', (string)$archiveData['timestamp']) |
|
| 53 | + ? DateTimeImmutable::createFromFormat('U', (string) $archiveData['timestamp']) |
|
| 54 | 54 | : null |
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | protected function requestWikiwixApi(string $url): array |
| 59 | 59 | { |
| 60 | - $response = $this->externHttpClient->get(self::API_URL . urlencode($url), [ |
|
| 60 | + $response = $this->externHttpClient->get(self::API_URL.urlencode($url), [ |
|
| 61 | 61 | 'timeout' => 20, |
| 62 | 62 | 'allow_redirects' => true, |
| 63 | 63 | 'headers' => ['User-Agent' => getenv('USER_AGENT')], |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | $data = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR) ?? []; |
| 76 | 76 | |
| 77 | 77 | // check wikiwix archive status |
| 78 | - if (empty($data['status']) || (int)$data['status'] !== 200) { |
|
| 79 | - $this->log->debug('WikiwixAdapter incorrect response: ' . $jsonString); |
|
| 78 | + if (empty($data['status']) || (int) $data['status'] !== 200) { |
|
| 79 | + $this->log->debug('WikiwixAdapter incorrect response: '.$jsonString); |
|
| 80 | 80 | |
| 81 | 81 | return []; |
| 82 | 82 | } |