@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | // todo verify http_build_query() enc_type parameter |
| 114 | 114 | // todo http_build_query() process an urlencode, but a not encoded q= value ("fu+bar") is beautiful |
| 115 | - return $googleURL . '?' . http_build_query($dat); |
|
| 115 | + return $googleURL.'?'.http_build_query($dat); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public static function isGoogleBookURL(string $text): bool |
| 122 | 122 | { |
| 123 | - return preg_match('#^' . self::GOOGLEBOOKS_START_URL_PATTERN . '[^>\]} \n]+$#i', $text) > 0; |
|
| 123 | + return preg_match('#^'.self::GOOGLEBOOKS_START_URL_PATTERN.'[^>\]} \n]+$#i', $text) > 0; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | private static function isNewGoogleBookUrl(string $url): bool |
| 154 | 154 | { |
| 155 | - return (bool)preg_match( |
|
| 156 | - '#^' . self::GOOGLEBOOKS_NEW_START_URL_PATTERN . self::GOOGLEBOOKS_ID_REGEX . '(?:&.+)?#', |
|
| 155 | + return (bool) preg_match( |
|
| 156 | + '#^'.self::GOOGLEBOOKS_NEW_START_URL_PATTERN.self::GOOGLEBOOKS_ID_REGEX.'(?:&.+)?#', |
|
| 157 | 157 | $url |
| 158 | 158 | ); |
| 159 | 159 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | private static function getIDFromNewGBurl(string $url): ?string |
| 232 | 232 | { |
| 233 | 233 | if (preg_match( |
| 234 | - '#^' . self::GOOGLEBOOKS_NEW_START_URL_PATTERN . '(' . self::GOOGLEBOOKS_ID_REGEX . ')(?:&.+)?#', |
|
| 234 | + '#^'.self::GOOGLEBOOKS_NEW_START_URL_PATTERN.'('.self::GOOGLEBOOKS_ID_REGEX.')(?:&.+)?#', |
|
| 235 | 235 | $url, |
| 236 | 236 | $matches |
| 237 | 237 | ) |
@@ -244,6 +244,6 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | protected static function validateGoogleBooksId(string $id): bool |
| 246 | 246 | { |
| 247 | - return preg_match('#' . self::GOOGLEBOOKS_ID_REGEX . '#', $id) > 0; |
|
| 247 | + return preg_match('#'.self::GOOGLEBOOKS_ID_REGEX.'#', $id) > 0; |
|
| 248 | 248 | } |
| 249 | 249 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | public function deleteEmptyValueArray(array $array): array |
| 28 | 28 | { |
| 29 | - return array_filter($array, function ($value) { |
|
| 29 | + return array_filter($array, function($value) { |
|
| 30 | 30 | return (null !== $value && '' !== $value); |
| 31 | 31 | }); |
| 32 | 32 | } |
@@ -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; |
@@ -155,7 +155,7 @@ |
||
| 155 | 155 | protected function isValidParamName($name): bool |
| 156 | 156 | { |
| 157 | 157 | if (is_int($name)) { |
| 158 | - $name = (string)$name; |
|
| 158 | + $name = (string) $name; |
|
| 159 | 159 | } |
| 160 | 160 | // that parameter exists in template ? |
| 161 | 161 | // @phpstan-ignore-next-line |
@@ -328,7 +328,7 @@ |
||
| 328 | 328 | 'modifs' => mb_substr(implode(',', $this->getSummaryLog()), 0, 250), |
| 329 | 329 | 'notcosmetic' => ($this->notCosmetic) ? 1 : 0, |
| 330 | 330 | 'major' => ($this->major) ? 1 : 0, |
| 331 | - 'isbn' => substr($isbn,0,19), |
|
| 331 | + 'isbn' => substr($isbn, 0, 19), |
|
| 332 | 332 | 'version' => WikiBotConfig::VERSION ?? null, |
| 333 | 333 | ]; |
| 334 | 334 | $this->log->info('finalData', $finalData); |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | if (isset($meta['citation_firstpage'])) { |
| 112 | 112 | $page = $meta['citation_firstpage']; |
| 113 | 113 | if (isset($meta['citation_lastpage'])) { |
| 114 | - $page .= '–' . $meta['citation_lastpage']; |
|
| 114 | + $page .= '–'.$meta['citation_lastpage']; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - return (string)$page; |
|
| 117 | + return (string) $page; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return null; |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $this->log->notice('EXCEPTION DATE'); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return '<!-- ' . $str . ' -->'; |
|
| 343 | + return '<!-- '.$str.' -->'; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | return $date->format('d-m-Y'); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | // Attention : pas de post-processing (sanitize title, etc.) |
| 35 | 35 | $result = $trans->process($url, $summary); |
| 36 | 36 | } catch (Exception $e) { |
| 37 | - echo "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine(); |
|
| 37 | + echo "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine(); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | echo $result."\n"; |
@@ -274,7 +274,7 @@ |
||
| 274 | 274 | if (mb_strlen($text) > $maxLength) { |
| 275 | 275 | $spacePos = mb_strrpos(mb_substr($text, 0, $maxLength), ' '); |
| 276 | 276 | $spacePos = ($spacePos > ($maxLength - 12)) ? $spacePos : $maxLength; |
| 277 | - $text = trim(mb_substr($text, 0, $spacePos)) . self::SYMBOL_TEXT_CUT; |
|
| 277 | + $text = trim(mb_substr($text, 0, $spacePos)).self::SYMBOL_TEXT_CUT; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | return $text; |