Passed
Push — master ( 732591...229bc5 )
by Dispositif
03:49
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/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/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.
src/Infrastructure/InternetArchiveAdapter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         return new WebarchiveDTO(
46 46
             self::ARCHIVER_NAME,
47 47
             $url,
48
-            (string)$archiveData['url'],
48
+            (string) $archiveData['url'],
49 49
             $iaDateOrNull
50 50
         );
51 51
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     protected function requestInternetArchiveApi(string $url, ?DateTimeInterface $date = null): array
54 54
     {
55 55
         $response = $this->client->get(
56
-            'https://archive.org/wayback/available?timestamp=' . self::SEARCH_CLOSEST_TIMESTAMP . '&url=' . urlencode($url),
56
+            'https://archive.org/wayback/available?timestamp='.self::SEARCH_CLOSEST_TIMESTAMP.'&url='.urlencode($url),
57 57
             [
58 58
                 'timeout' => 20,
59 59
                 'allow_redirects' => true,
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
         }
104 104
         $iaDateTime = new DateTime();
105 105
         $iaDateTime->setDate(
106
-            (int)substr($iaTimestamp, 0, 4),
107
-            (int)substr($iaTimestamp, 4, 2),
108
-            (int)substr($iaTimestamp, 6, 2)
106
+            (int) substr($iaTimestamp, 0, 4),
107
+            (int) substr($iaTimestamp, 4, 2),
108
+            (int) substr($iaTimestamp, 6, 2)
109 109
         );
110 110
         $iaDateTime->setTime(
111
-            (int)substr($iaTimestamp, 8, 2),
112
-            (int)substr($iaTimestamp, 10, 2),
113
-            (int)substr($iaTimestamp, 12, 2)
111
+            (int) substr($iaTimestamp, 8, 2),
112
+            (int) substr($iaTimestamp, 10, 2),
113
+            (int) substr($iaTimestamp, 12, 2)
114 114
         );
115 115
 
116 116
         return $iaDateTime;
Please login to merge, or discard this patch.
src/Application/AbstractRefBotWorker.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function hasWarning(): bool
26 26
     {
27
-        return (bool)$this->warning;
27
+        return (bool) $this->warning;
28 28
     }
29 29
 
30 30
     /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $refs = array_slice($refs, 0, self::MAX_REFS_PROCESSED_IN_ARTICLE, true);
56 56
 
57 57
         foreach ($refs as $ref) {
58
-            $refContent = WikiTextUtil::stripFinalPoint(trim((string)$ref[1]));
58
+            $refContent = WikiTextUtil::stripFinalPoint(trim((string) $ref[1]));
59 59
 
60 60
             $newRefContent = $this->processRefContent($refContent);
61 61
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
     protected function replaceRefInText(array $ref, string $replace, string $text)
71 71
     {
72 72
         // Pas de changement
73
-        if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string)$ref[1]))) {
73
+        if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string) $ref[1]))) {
74 74
             return $text;
75 75
         }
76 76
         $replace = $this->addFinalPeriod($ref[0], $replace);
77
-        $result = str_replace($ref[1], $replace, (string)$ref[0]);
77
+        $result = str_replace($ref[1], $replace, (string) $ref[0]);
78 78
         $this->printDiff($ref[0], $result);
79 79
 
80 80
         return str_replace($ref[0], $result, $text);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     protected function addFinalPeriod($ref, string $replace): string
87 87
     {
88
-        if (preg_match('#</ref>#', (string)$ref)) {
88
+        if (preg_match('#</ref>#', (string) $ref)) {
89 89
             $replace .= '.';
90 90
         }
91 91
         return $replace;
Please login to merge, or discard this patch.
src/Application/CLI/lastExternRefProcess.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@
 block discarded – undo
56 56
 $titles = $list->getPageTitles();
57 57
 unset($list);
58 58
 //echo count($titles)." titles\n";
59
-$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
59
+$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
60 60
 $filtered = array_diff($titles, $edited);
61 61
 $list = new PageList($filtered);
62
-echo ">" . $list->count() . " dans liste\n";
62
+echo ">".$list->count()." dans liste\n";
63 63
 
64 64
 
65 65
 $httpClient = ServiceFactory::getHttpClient();
Please login to merge, or discard this patch.
src/Application/CLI/testExternLink.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 // todo command --tor --wikiwix --internetarchive
39 39
 $torEnabled = false;
40
-echo "TOR enabled : ".($torEnabled ? "oui" : "non"). "\n";
40
+echo "TOR enabled : ".($torEnabled ? "oui" : "non")."\n";
41 41
 
42 42
 $client = ServiceFactory::getHttpClient();
43 43
 $wikiwix = new WikiwixAdapter($client, $logger);
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     // Attention : pas de post-processing (sanitize title, etc.)
57 57
     $result = $trans->process($url, $summary);
58 58
 } catch (Exception $e) {
59
-    $result = "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine();
59
+    $result = "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine();
60 60
 }
61 61
 
62
-echo '>>> '. $result."\n";
62
+echo '>>> '.$result."\n";
63 63
 
64 64
 
65 65
 
Please login to merge, or discard this patch.