Passed
Push — master ( f4fa9e...860b7e )
by Dispositif
12:07
created
src/Infrastructure/WikiwixAdapter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Application/Utils/HttpUtil.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public static function isHttpURL(string $url): bool
24 24
     {
25
-        return (bool)preg_match('#^https?://[^ ]+$#i', $url);
25
+        return (bool) preg_match('#^https?://[^ ]+$#i', $url);
26 26
     }
27 27
 
28 28
     /**
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 
43 43
         $charset = self::extractCharset($html) ?? 'WINDOWS-1252';
44 44
         if (empty($charset)) {
45
-            throw new DomainException('normalized html error and no charset found : ' . $url);
45
+            throw new DomainException('normalized html error and no charset found : '.$url);
46 46
         }
47 47
         try {
48 48
             // PHP Notice:  iconv(): Detected an illegal character in input string
49 49
             $html2 = @iconv($charset, 'UTF-8//TRANSLIT', $html);
50 50
             if (false === $html2) {
51
-                throw new DomainException("error iconv : $charset to UTF-8 on " . $url);
51
+                throw new DomainException("error iconv : $charset to UTF-8 on ".$url);
52 52
             }
53 53
             $html2 = Normalizer::normalize($html2);
54 54
             if (!is_string($html2)) {
55
-                throw new DomainException("error normalizer : $charset to UTF-8 on " . $url);
55
+                throw new DomainException("error normalizer : $charset to UTF-8 on ".$url);
56 56
             }
57 57
         } catch (Throwable $e) {
58
-            throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e);
58
+            throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e);
59 59
         }
60 60
 
61 61
         return $html2;
Please login to merge, or discard this patch.
src/Application/OuvrageEdit/OuvrageEditWorker.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     final public const DELAY_BOTFLAG_SECONDS = 60;
48 48
     final public const DELAY_NO_BOTFLAG_SECONDS = 60;
49 49
     final public const DELAY_MINUTES_AFTER_HUMAN_EDIT = 10;
50
-    final public const ERROR_MSG_TEMPLATE = __DIR__ . '/templates/message_errors.wiki';
50
+    final public const ERROR_MSG_TEMPLATE = __DIR__.'/templates/message_errors.wiki';
51 51
 
52 52
     /**
53 53
      * @var PageWorkStatus
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     {
93 93
         while (true) {
94 94
             echo "\n-------------------------------------\n\n";
95
-            echo date("Y-m-d H:i:s") . " ";
95
+            echo date("Y-m-d H:i:s")." ";
96 96
             $this->log->info($this->memory->getMemory(true));
97 97
             $this->pageProcess();
98 98
             sleep(2); // précaution boucle infinie
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         try {
125 125
             $this->wikiPageAction = ServiceFactory::wikiPageAction($this->pageWorkStatus->getTitle()); // , true ?
126 126
         } catch (Exception) {
127
-            $this->log->warning("*** WikiPageAction error : " . $this->pageWorkStatus->getTitle() . " \n");
127
+            $this->log->warning("*** WikiPageAction error : ".$this->pageWorkStatus->getTitle()." \n");
128 128
             sleep(20);
129 129
 
130 130
             return false;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
     protected function printTitle(string $title): void
162 162
     {
163
-        echo Color::BG_CYAN . $title . Color::NORMAL . " \n";
163
+        echo Color::BG_CYAN.$title.Color::NORMAL." \n";
164 164
     }
165 165
 
166 166
     protected function checkArticleLabels($title): void
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 
234 234
     protected function printDebug(array $data)
235 235
     {
236
-        $this->log->debug('origin: ' . $data['raw']);
237
-        $this->log->debug('completed: ' . $data['opti']);
238
-        $this->log->debug('modifs: ' . $data['modifs']);
239
-        $this->log->debug('version: ' . $data['version']);
236
+        $this->log->debug('origin: '.$data['raw']);
237
+        $this->log->debug('completed: '.$data['opti']);
238
+        $this->log->debug('modifs: '.$data['modifs']);
239
+        $this->log->debug('version: '.$data['version']);
240 240
     }
241 241
 
242 242
     protected function editPage(): bool
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                 $this->log->alert("*** Invalid CSRF token \n");
256 256
                 throw new Exception('Invalid CSRF token', $e->getCode(), $e);
257 257
             } else {
258
-                $this->log->warning('Exception in editPage() ' . $e->getMessage());
258
+                $this->log->warning('Exception in editPage() '.$e->getMessage());
259 259
                 sleep(10);
260 260
 
261 261
                 return false;
@@ -277,16 +277,16 @@  discard block
 block discarded – undo
277 277
                 $this->sendOuvrageErrorsOnTalkPage($pageOuvrageCollection, $this->log);
278 278
             }
279 279
         } catch (Throwable $e) {
280
-            $this->log->warning('Exception in editPage() ' . $e->getMessage());
280
+            $this->log->warning('Exception in editPage() '.$e->getMessage());
281 281
             unset($e);
282 282
         }
283 283
 
284 284
         if (!$this->pageWorkStatus->botFlag) {
285
-            $this->log->debug("sleep " . self::DELAY_NO_BOTFLAG_SECONDS);
285
+            $this->log->debug("sleep ".self::DELAY_NO_BOTFLAG_SECONDS);
286 286
             sleep(self::DELAY_NO_BOTFLAG_SECONDS);
287 287
         }
288 288
         if ($this->pageWorkStatus->botFlag) {
289
-            $this->log->debug("sleep " . self::DELAY_BOTFLAG_SECONDS);
289
+            $this->log->debug("sleep ".self::DELAY_BOTFLAG_SECONDS);
290 290
             sleep(self::DELAY_BOTFLAG_SECONDS);
291 291
         }
292 292
     }
Please login to merge, or discard this patch.
src/Application/TalkBotConfig.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 class TalkBotConfig extends WikiBotConfig
24 24
 {
25 25
     final public const BOT_TALK_SUMMARY = 'Réponse artificielle';
26
-    final public const BOT_TALK_FILE = __DIR__ . '/resources/phrases_zizibot.txt';
27
-    final public const TALKCONFIG_FILENAME = __DIR__ . '/resources/botTalk_config.json';
26
+    final public const BOT_TALK_FILE = __DIR__.'/resources/phrases_zizibot.txt';
27
+    final public const TALKCONFIG_FILENAME = __DIR__.'/resources/botTalk_config.json';
28 28
 
29 29
     /**
30 30
      * Add a freaky response in the bottom of the talk page.
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         // ugly dependency
38 38
         $wiki = ServiceFactory::getMediawikiFactory();
39 39
         if (!$pageTitle) {
40
-            $pageTitle = 'Discussion utilisateur:' . $this::getBotName();
40
+            $pageTitle = 'Discussion utilisateur:'.$this::getBotName();
41 41
         }
42 42
         $page = new WikiPageAction($wiki, $pageTitle);
43 43
         $last = $page->page->getRevisions()->getLatest();
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 
58 58
         // No response if time < 24h since last bot owner response
59 59
         if ($last->getUser() == self::getBotOwner()) {
60
-            $talkConfig['owner_last_time'] = (int)strtotime($last->getTimestamp());
60
+            $talkConfig['owner_last_time'] = (int) strtotime($last->getTimestamp());
61 61
             file_put_contents(self::TALKCONFIG_FILENAME, json_encode($talkConfig, JSON_THROW_ON_ERROR));
62 62
 
63 63
             return false;
64 64
         }
65 65
         // No response if time < 24h since last owner response
66
-        if (isset($talkConfig['owner_last_time']) && (int)$talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) {
66
+        if (isset($talkConfig['owner_last_time']) && (int) $talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) {
67 67
             echo "No response if time < 24h after last owner response\n";
68 68
 
69 69
             return false;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $editInfo = new EditInfo(static::BOT_TALK_SUMMARY);
80 80
         $success = $page->addToBottomOfThePage($addText, $editInfo);
81 81
 
82
-        return (bool)$success;
82
+        return (bool) $success;
83 83
     }
84 84
 
85 85
     /**
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
         $lines = explode("\n", trim($text));
111 111
         $lastLine = $lines[count($lines) - 1];
112 112
         if (preg_match('#^(:*).+#', $lastLine, $matches) && !empty($matches[1])) {
113
-            $nextIdent = $matches[1] . ':';
113
+            $nextIdent = $matches[1].':';
114 114
             if (empty($author)) {
115 115
                 return $nextIdent;
116 116
             }
117 117
             // search author signature link to check that he wrote on the page bottom
118 118
             if (preg_match(
119
-                '#\[\[(?:User|Utilisateur|Utilisatrice):' . preg_quote($author, '#') . '[|\]]#i',
119
+                '#\[\[(?:User|Utilisateur|Utilisatrice):'.preg_quote($author, '#').'[|\]]#i',
120 120
                 $matches[0]
121 121
             )
122 122
             ) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             throw new ConfigException('Pas de phrases disponibles pour TalkBot');
138 138
         }
139 139
 
140
-        return (string)trim($sentences[array_rand($sentences)]);
140
+        return (string) trim($sentences[array_rand($sentences)]);
141 141
     }
142 142
 
143 143
     /**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         // TODO client
150 150
         $url
151
-            = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=' . $this::getBotName()
151
+            = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser='.$this::getBotName()
152 152
             . '&ucnamespace=0&uclimit=40&ucprop=title|timestamp|comment&format=json';
153 153
 
154 154
         return file_get_contents($url);
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternHttpErrorLogic.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class ExternHttpErrorLogic
20 20
 {
21
-    final public const LOG_REQUEST_ERROR = __DIR__ . '/../../Application/resources/external_request_error.log';
21
+    final public const LOG_REQUEST_ERROR = __DIR__.'/../../Application/resources/external_request_error.log';
22 22
     protected const LOOSE = true;
23 23
 
24 24
     public function __construct(
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
             return $url;
41 41
         }
42 42
         if (preg_match('#400 Bad Request#i', $errorMessage)) {
43
-            $this->log->warning('400 Bad Request : ' . $url);
43
+            $this->log->warning('400 Bad Request : '.$url);
44 44
 
45 45
             return $url;
46 46
         }
47 47
         if (preg_match('#(403 Forbidden|403 Access Forbidden)#i', $errorMessage)) {
48
-            $this->log->warning('403 Forbidden : ' . $url);
48
+            $this->log->warning('403 Forbidden : '.$url);
49 49
             // TODO return blankLienWeb without consulté le=...
50 50
 
51 51
             return $url;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             return $url;
60 60
         }
61 61
         if (preg_match('#401 (Unauthorized|Authorization Required)#i', $errorMessage)) {
62
-            $this->log->notice('401 Unauthorized : skip ' . $url);
62
+            $this->log->notice('401 Unauthorized : skip '.$url);
63 63
 
64 64
             return $url;
65 65
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         // "URL rejected: No host part in the URL (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
105 105
         // "cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
106 106
         //"cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
107
-        $this->log->notice('erreur non gérée sur extractWebData: "' . $errorMessage . "\" URL: " . $url);
107
+        $this->log->notice('erreur non gérée sur extractWebData: "'.$errorMessage."\" URL: ".$url);
108 108
 
109 109
         //file_put_contents(self::LOG_REQUEST_ERROR, $this->domain."\n", FILE_APPEND);
110 110
 
Please login to merge, or discard this patch.
src/Domain/ExternLink/DeadLinkTransformer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
             $webarchive = $this->archiver->searchWebarchive($url);
45 45
             if ($webarchive instanceof WebarchiveDTO) {
46 46
                 $this->log->notice('
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternRefTransformer.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
     use SummaryExternTrait, PublisherLogicTrait;
36 36
 
37 37
     final public const HTTP_REQUEST_LOOP_DELAY = 10;
38
-    final public const SKIP_DOMAIN_FILENAME = __DIR__ . '/../resources/config_skip_domain.txt';
38
+    final public const SKIP_DOMAIN_FILENAME = __DIR__.'/../resources/config_skip_domain.txt';
39 39
     final public const REPLACE_404 = true;
40 40
     final public const REPLACE_410 = true;
41
-    final public const CONFIG_PRESSE = __DIR__ . '/../resources/config_presse.yaml';
42
-    final public const CONFIG_NEWSPAPER_JSON = __DIR__ . '/../resources/data_newspapers.json';
43
-    final public const CONFIG_SCIENTIFIC_JSON = __DIR__ . '/../resources/data_scientific_domain.json';
44
-    final public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__ . '/../resources/data_scientific_wiki.json';
41
+    final public const CONFIG_PRESSE = __DIR__.'/../resources/config_presse.yaml';
42
+    final public const CONFIG_NEWSPAPER_JSON = __DIR__.'/../resources/data_newspapers.json';
43
+    final public const CONFIG_SCIENTIFIC_JSON = __DIR__.'/../resources/data_scientific_domain.json';
44
+    final public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__.'/../resources/data_scientific_wiki.json';
45 45
 
46 46
     public bool $skipSiteBlacklisted = true;
47 47
     public bool $skipRobotNoIndex = true;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
         }
94 94
         $this->registrableDomain = $this->urlChecker->getRegistrableDomain($url); // hack
95 95
         if ($this->isSiteBlackListed()) {
96
-            $this->log->debug('Site blacklisted : ' . $this->registrableDomain);
96
+            $this->log->debug('Site blacklisted : '.$this->registrableDomain);
97 97
             return $url;
98 98
         }
99 99
 
100 100
         if (!$this->validateConfigWebDomain($this->registrableDomain)) {
101
-            $this->log->debug('Domain not validate by config : ' . $this->registrableDomain);
101
+            $this->log->debug('Domain not validate by config : '.$this->registrableDomain);
102 102
             return $url;
103 103
         }
104 104
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     protected function isSiteBlackListed(): bool
151 151
     {
152 152
         if ($this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) {
153
-            $this->log->notice("Skip web site " . $this->registrableDomain);
153
+            $this->log->notice("Skip web site ".$this->registrableDomain);
154 154
             return true;
155 155
         }
156 156
         return false;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : [];
169 169
 
170 170
         if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) {
171
-            $this->log->info("Domain " . $domain . " disabled\n");
171
+            $this->log->info("Domain ".$domain." disabled\n");
172 172
 
173 173
             return false;
174 174
         }
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
     protected function logDebugConfigWebDomain(string $domain): void
180 180
     {
181 181
         if (!isset($this->config[$domain])) {
182
-            $this->log->debug("Domain " . $domain . " non configuré");
182
+            $this->log->debug("Domain ".$domain." non configuré");
183 183
         } else {
184
-            $this->log->debug("Domain " . $domain . " configuré");
184
+            $this->log->debug("Domain ".$domain." configuré");
185 185
         }
186 186
     }
187 187
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         if ($pageData === []
208 208
             || (empty($pageData['JSON-LD']) && empty($pageData['meta']))
209 209
         ) {
210
-            $this->log->notice('No metadata : ' . $url);
210
+            $this->log->notice('No metadata : '.$url);
211 211
 
212 212
             return true;
213 213
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     protected function emptyMapData(array $mapData, string $url): bool
223 223
     {
224 224
         if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) {
225
-            $this->log->info('Mapping incomplet : ' . $url);
225
+            $this->log->info('Mapping incomplet : '.$url);
226 226
 
227 227
             return true;
228 228
         }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
         $template = WikiTemplateFactory::create($templateName);
277 277
         $template->userSeparator = " |";
278
-        $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0);
278
+        $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0);
279 279
 
280 280
         return $template;
281 281
     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $templateOptimized = $optimizer->getOptiTemplate();
332 332
 
333 333
         $serialized = $templateOptimized->serialize(true);
334
-        $this->log->info('Serialized 444: ' . $serialized . "\n");
334
+        $this->log->info('Serialized 444: '.$serialized."\n");
335 335
         return $serialized;
336 336
     }
337 337
 
Please login to merge, or discard this patch.
src/Domain/WikiOptimizer/Handlers/LocationHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 class LocationHandler extends AbstractOuvrageHandler
20 20
 {
21
-    final public const TRANSLATE_CITY_FR = __DIR__ . '/../../resources/traduction_ville.csv';
21
+    final public const TRANSLATE_CITY_FR = __DIR__.'/../../resources/traduction_ville.csv';
22 22
 
23 23
     /**
24 24
      * @var PageListInterface
Please login to merge, or discard this patch.
src/Domain/WikiOptimizer/OuvrageOptimize.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 {
36 36
     final public const CONVERT_GOOGLEBOOK_TEMPLATE = false; // change OuvrageOptimizeTest !!
37 37
     final public const WIKI_LANGUAGE = 'fr';
38
-    final public const PUBLISHER_FRWIKI_FILENAME = __DIR__ . '/../resources/data_editors_wiki.json';
38
+    final public const PUBLISHER_FRWIKI_FILENAME = __DIR__.'/../resources/data_editors_wiki.json';
39 39
 
40 40
     /**
41 41
      * @var OptiStatus
Please login to merge, or discard this patch.