@@ -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 | } |
@@ -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 |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // rebuild title but keep only the first 2 segments |
| 57 | - return trim($titleSegments[0]) . self::REBUILD_SEPARATOR . trim($titleSegments[1]); |
|
| 57 | + return trim($titleSegments[0]).self::REBUILD_SEPARATOR.trim($titleSegments[1]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | return array_values(array_filter( |
| 104 | 104 | $seoSegments, |
| 105 | - function ($segment) use ($prettyDomainName, $siteName) { |
|
| 105 | + function($segment) use ($prettyDomainName, $siteName) { |
|
| 106 | 106 | $strippedSegment = mb_strtolower(TextUtil::stripPunctuation(TextUtil::stripAccents($segment))); |
| 107 | 107 | $strippedSegment = str_replace(['.', '-', ' '], '', $strippedSegment); |
| 108 | 108 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | if ($this->modeAuto) { |
| 24 | 24 | return true; |
| 25 | 25 | } |
| 26 | - $ask = readline(Color::LIGHT_MAGENTA . '*** '.$question.' [y/n/auto]' . Color::NORMAL); |
|
| 26 | + $ask = readline(Color::LIGHT_MAGENTA.'*** '.$question.' [y/n/auto]'.Color::NORMAL); |
|
| 27 | 27 | if ('auto' === $ask) { |
| 28 | 28 | $this->modeAuto = true; |
| 29 | 29 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES |
| 25 | 25 | ); |
| 26 | 26 | } catch (Throwable $e) { |
| 27 | - $this->log->critical("Can't parse ARTICLE_ANALYZED_FILENAME : " . $e->getMessage()); |
|
| 27 | + $this->log->critical("Can't parse ARTICLE_ANALYZED_FILENAME : ".$e->getMessage()); |
|
| 28 | 28 | $analyzed = []; |
| 29 | 29 | } |
| 30 | 30 | $this->pastAnalyzed = ($analyzed !== false) ? $analyzed : []; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | if (!$this->checkAlreadyAnalyzed($title)) { |
| 36 | 36 | $this->pastAnalyzed[] = $title; // skip doublon title |
| 37 | - @file_put_contents(static::ARTICLE_ANALYZED_FILENAME, $title . PHP_EOL, FILE_APPEND); |
|
| 37 | + @file_put_contents(static::ARTICLE_ANALYZED_FILENAME, $title.PHP_EOL, FILE_APPEND); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | protected function printTitle(string $title): void |
| 53 | 53 | { |
| 54 | 54 | echo "---------------------\n"; |
| 55 | - echo date('d-m-Y H:i:s') . ' ' . Color::BG_CYAN . " $title " . Color::NORMAL . "\n"; |
|
| 55 | + echo date('d-m-Y H:i:s').' '.Color::BG_CYAN." $title ".Color::NORMAL."\n"; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | protected function canProcessTitleArticle(string $title, ?string $text): bool |
@@ -51,9 +51,9 @@ |
||
| 51 | 51 | sleep(60 * 10); |
| 52 | 52 | exit; |
| 53 | 53 | } |
| 54 | - if(preg_match('#Quota exceeded#', $e->getMessage())) { |
|
| 54 | + if (preg_match('#Quota exceeded#', $e->getMessage())) { |
|
| 55 | 55 | echo "ouvrageCompleteProcess : Quota exceeded. Sleep 4h and EXIT."; |
| 56 | - sleep(60*60*4); |
|
| 56 | + sleep(60 * 60 * 4); |
|
| 57 | 57 | exit; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -37,25 +37,25 @@ discard block |
||
| 37 | 37 | $data = []; |
| 38 | 38 | |
| 39 | 39 | $monitor = $db->fetchRow('select count(id) from page_ouvrages where optidate is null and edited is null and skip=0'); |
| 40 | -$data['not analyzed citation'] = (int)$monitor['count(id)']; |
|
| 40 | +$data['not analyzed citation'] = (int) $monitor['count(id)']; |
|
| 41 | 41 | |
| 42 | 42 | $monitor = $db->fetchRow('select count(id) from page_ouvrages where optidate is not null'); |
| 43 | -$data['analyzed citation'] = (int)$monitor['count(id)']; |
|
| 43 | +$data['analyzed citation'] = (int) $monitor['count(id)']; |
|
| 44 | 44 | |
| 45 | 45 | $monitor = $db->fetchRow('select count(distinct page) as n from page_ouvrages where skip=1 and edited is null'); // ? |
| 46 | -$data['skip pages'] = (int)$monitor['n']; |
|
| 46 | +$data['skip pages'] = (int) $monitor['n']; |
|
| 47 | 47 | |
| 48 | 48 | $monitor = $db->fetchRow('select count(distinct page) as n from page_ouvrages where edited is true'); |
| 49 | -$data['edited pages'] = (int)$monitor['n']; |
|
| 49 | +$data['edited pages'] = (int) $monitor['n']; |
|
| 50 | 50 | |
| 51 | 51 | $monitor = $db->fetchRow('select count(id) from page_ouvrages where optidate > SUBDATE(NOW(),1)'); |
| 52 | -$data['analyzed citation 24H'] = (int)$monitor['count(id)']; |
|
| 52 | +$data['analyzed citation 24H'] = (int) $monitor['count(id)']; |
|
| 53 | 53 | |
| 54 | 54 | $monitor = $db->fetchRow('select count(id) as n from page_ouvrages where edited > SUBDATE(NOW(),1)'); |
| 55 | -$data['edited citations 24H'] = (int)$monitor['n']; |
|
| 55 | +$data['edited citations 24H'] = (int) $monitor['n']; |
|
| 56 | 56 | |
| 57 | 57 | $monitor = $db->fetchRow('select count(distinct page) as n from page_ouvrages where edited > SUBDATE(NOW(),1)'); |
| 58 | -$data['edited pages 24H'] = (int)$monitor['n']; |
|
| 58 | +$data['edited pages 24H'] = (int) $monitor['n']; |
|
| 59 | 59 | |
| 60 | 60 | $monitor = $db->fetchRow( |
| 61 | 61 | 'SELECT count(distinct A.page) FROM page_ouvrages A |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | AND A.page = B.page |
| 75 | 75 | )' |
| 76 | 76 | ); |
| 77 | -$data['waiting pages'] = (int)$monitor['count(distinct A.page)']; |
|
| 77 | +$data['waiting pages'] = (int) $monitor['count(distinct A.page)']; |
|
| 78 | 78 | |
| 79 | 79 | $data['currentdate'] = DateUtil::english2french((new DateTime())->format('j F Y \à H\:i').' (CEST)'); |
| 80 | 80 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $sender = getenv('BOT_NAME') ?? ''; |
| 43 | 43 | $message = sprintf('%s : %s', $sender, $message); |
| 44 | - $url = getenv('FREE_SMS_URL') . urlencode($message); |
|
| 44 | + $url = getenv('FREE_SMS_URL').urlencode($message); |
|
| 45 | 45 | |
| 46 | 46 | $response = $this->client->get($url, ['timeout' => 120]); |
| 47 | 47 | |