@@ -36,7 +36,7 @@ |
||
| 36 | 36 | echo $e->getMessage(); |
| 37 | 37 | if ($count > 2) { |
| 38 | 38 | echo "\n3 erreurs à la suite => sleep 2h + exit\n"; |
| 39 | - sleep(3600* 2); |
|
| 39 | + sleep(3600 * 2); |
|
| 40 | 40 | exit; |
| 41 | 41 | } |
| 42 | 42 | unset($e); |
@@ -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 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return string|null |
| 51 | 51 | */ |
| 52 | - public function getHTML(string $url, ?bool $normalized=false): ?string |
|
| 52 | + public function getHTML(string $url, ?bool $normalized = false): ?string |
|
| 53 | 53 | { |
| 54 | 54 | // todo : check banned domains ? |
| 55 | 55 | // todo : check DNS record => ban ? |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | return null; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $html = (string)$response->getBody()->getContents() ?? ''; |
|
| 74 | + $html = (string) $response->getBody()->getContents() ?? ''; |
|
| 75 | 75 | |
| 76 | 76 | return ($normalized) ? $this->normalizeHtml($html, $url) : $html; |
| 77 | 77 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | private function normalizeHtml(string $html, ?string $url = ''): ?string |
| 100 | 100 | { |
| 101 | - if(empty($html)) { |
|
| 101 | + if (empty($html)) { |
|
| 102 | 102 | return $html; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -13,5 +13,5 @@ |
||
| 13 | 13 | |
| 14 | 14 | interface HttpClientInterface |
| 15 | 15 | { |
| 16 | - public function getHTML(string $url, ?bool $normalized=false): ?string; |
|
| 16 | + public function getHTML(string $url, ?bool $normalized = false): ?string; |
|
| 17 | 17 | } |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | $this->defaultTaskname = $bot->taskName; |
| 86 | 86 | |
| 87 | 87 | $analyzed = @file(static::ARTICLE_ANALYZED_FILENAME, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 88 | - $this->pastAnalyzed = ($analyzed !== false ) ? $analyzed : []; |
|
| 88 | + $this->pastAnalyzed = ($analyzed !== false) ? $analyzed : []; |
|
| 89 | 89 | |
| 90 | 90 | // @throw exception on "Invalid CSRF token" |
| 91 | - $this->run();//todo delete that and use (Worker)->run($duration) or process management |
|
| 91 | + $this->run(); //todo delete that and use (Worker)->run($duration) or process management |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | protected function setUpInConstructor(): void |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | protected function titleProcess(string $title): void |
| 133 | 133 | { |
| 134 | 134 | echo "---------------------\n"; |
| 135 | - echo date('d-m-Y H:i'). ' '. Color::BG_CYAN." $title ".Color::NORMAL."\n"; |
|
| 135 | + echo date('d-m-Y H:i').' '.Color::BG_CYAN." $title ".Color::NORMAL."\n"; |
|
| 136 | 136 | sleep(1); |
| 137 | 137 | |
| 138 | - if(in_array($title, $this->pastAnalyzed)) { |
|
| 138 | + if (in_array($title, $this->pastAnalyzed)) { |
|
| 139 | 139 | echo "Skip : déjà analysé\n"; |
| 140 | 140 | return; |
| 141 | 141 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->titleBotFlag = static::TASK_BOT_FLAG; |
| 145 | 145 | |
| 146 | 146 | $text = $this->getText($title); |
| 147 | - if( static::SKIP_LASTEDIT_BY_BOT && $this->pageAction->getLastEditor() === getenv('BOT_NAME') ) { |
|
| 147 | + if (static::SKIP_LASTEDIT_BY_BOT && $this->pageAction->getLastEditor() === getenv('BOT_NAME')) { |
|
| 148 | 148 | echo "Skip : déjà édité par le bot\n"; |
| 149 | 149 | return; |
| 150 | 150 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | dump($result); |
| 262 | - echo "Sleep ".(string)static::SLEEP_AFTER_EDITION."\n"; |
|
| 262 | + echo "Sleep ".(string) static::SLEEP_AFTER_EDITION."\n"; |
|
| 263 | 263 | sleep(static::SLEEP_AFTER_EDITION); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | return !empty($result); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function setLabel(string $title, ?int $val=0): bool |
|
| 184 | + public function setLabel(string $title, ?int $val = 0): bool |
|
| 185 | 185 | { |
| 186 | 186 | try { |
| 187 | 187 | $result = $this->db->update( |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string|null $url |
| 33 | 33 | * @param array|null $options |
| 34 | 34 | */ |
| 35 | - public function __construct(?string $url = null, ?array $options=[]) |
|
| 35 | + public function __construct(?string $url = null, ?array $options = []) |
|
| 36 | 36 | { |
| 37 | 37 | $this->url = $url; |
| 38 | 38 | $this->options = $options; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $titles[] = trim($res['title']); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(isset($this->options['reverse']) && $this->options['reverse'] === true ) { |
|
| 90 | + if (isset($this->options['reverse']) && $this->options['reverse'] === true) { |
|
| 91 | 91 | krsort($titles); |
| 92 | 92 | } |
| 93 | 93 | |