Passed
Push — master ( f4fa9e...860b7e )
by Dispositif
12:07
created
src/Application/WikiBotConfig.php 1 patch
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 class WikiBotConfig
32 32
 {
33 33
     public const VERSION = '2.1';
34
-    public const WATCHPAGE_FILENAME = __DIR__ . '/resources/watch_pages.json';
34
+    public const WATCHPAGE_FILENAME = __DIR__.'/resources/watch_pages.json';
35 35
     public const EXIT_ON_CHECK_WATCHPAGE = false;
36 36
     // do not stop if they play with {stop} on bot talk page
37 37
     public const BLACKLIST_EDITOR = ['OrlodrimBot'];
@@ -97,9 +97,8 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $text = WikiTextUtil::removeHTMLcomments($text);
99 99
         $botName = $botName ?: self::getBotName();
100
-        $denyReg = (empty($botName)) ? '' :
101
-            '|\{\{bots ?\| ?(optout|deny)\=[^\}]*' . preg_quote($botName, '#') . '[^\}]*\}\}';
102
-        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}' . $denyReg . ')#i', $text) > 0;
100
+        $denyReg = (empty($botName)) ? '' : '|\{\{bots ?\| ?(optout|deny)\=[^\}]*'.preg_quote($botName, '#').'[^\}]*\}\}';
101
+        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}'.$denyReg.')#i', $text) > 0;
103 102
     }
104 103
 
105 104
     protected static function getBotOwner()
@@ -155,7 +154,7 @@  discard block
 block discarded – undo
155 154
 
156 155
     protected function getBotTalkPageTitle(): string
157 156
     {
158
-        return self::TALK_PAGE_PREFIX . $this::getBotName();
157
+        return self::TALK_PAGE_PREFIX.$this::getBotName();
159 158
     }
160 159
 
161 160
     /**
@@ -266,8 +265,8 @@  discard block
 block discarded – undo
266 265
      */
267 266
     public function minutesSinceLastEdit(string $title): int
268 267
     {
269
-        $time = $this->getTimestamp($title);  // 2011-09-02T16:31:13Z
268
+        $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z
270 269
 
271
-        return (int)round((time() - strtotime($time)) / 60);
270
+        return (int) round((time() - strtotime($time)) / 60);
272 271
     }
273 272
 }
Please login to merge, or discard this patch.
src/Application/CLI/lastExternRefProcess.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 //echo count($titles)." titles\n";
79 79
 $edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
80 80
 $filtered = array_diff($titles, $edited);
81
-$list = new PageList( $filtered );
81
+$list = new PageList($filtered);
82 82
 echo ">".$list->count()." dans liste\n";
83 83
 
84 84
 new ExternRefWorker($botConfig, $wiki, $list, null, new InternetDomainParser());
Please login to merge, or discard this patch.
src/Infrastructure/InternetDomainParser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class InternetDomainParser implements InternetDomainParserInterface
23 23
 {
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
     private readonly Rules $rules;
27 27
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public static function extractSubdomainString(string $httpURL): string
56 56
     {
57 57
         if (!HttpUtil::isHttpURL($httpURL)) {
58
-            throw new Exception('string is not an URL ' . $httpURL);
58
+            throw new Exception('string is not an URL '.$httpURL);
59 59
         }
60 60
 
61 61
         return parse_url($httpURL, PHP_URL_HOST);
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternPage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     )
55 55
     {
56 56
         if (!HttpUtil::isHttpURL($url)) {
57
-            throw new Exception('string is not an URL ' . $url);
57
+            throw new Exception('string is not an URL '.$url);
58 58
         }
59 59
         $this->url = $url;
60 60
     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     {
171 171
         try {
172 172
             if (!HttpUtil::isHttpURL($this->url)) {
173
-                throw new Exception('string is not an URL ' . $this->url);
173
+                throw new Exception('string is not an URL '.$this->url);
174 174
             }
175 175
             if (!$this->domainParser instanceof InternetDomainParserInterface) {
176 176
                 $this->log->notice('InternetDomainParser is not set');
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             return $this->domainParser->getRegistrableDomainFromURL($this->url);
182 182
         } catch (Exception $e) {
183 183
             if ($this->log !== null) {
184
-                $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL ' . $this->url);
184
+                $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL '.$this->url);
185 185
             }
186 186
             throw new Exception('InternetDomainParser->getRegistrableDomainFromURL NULL', $e->getCode(), $e);
187 187
         }
Please login to merge, or discard this patch.
src/Domain/ExternLink/CheckURL.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $this->url = $url;
50 50
         $this->registrableDomain = null;
51 51
         if (!HttpUtil::isHttpURL($url)) {
52
-            $this->log->debug('Skip : not a valid URL : ' . $url);
52
+            $this->log->debug('Skip : not a valid URL : '.$url);
53 53
             return false;
54 54
         }
55 55
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             return false;
58 58
         }
59 59
         if (!HttpUtil::isHttpURL($url)) {
60
-            throw new Exception('string is not an URL ' . $url);
60
+            throw new Exception('string is not an URL '.$url);
61 61
         }
62 62
 
63 63
         $this->findRegistrableDomain();
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         try {
80 80
             $this->registrableDomain = $this->internetDomainParser->getRegistrableDomainFromURL($this->url);
81 81
         } catch (Exception) {
82
-            $this->log->warning('Skip : not a valid URL : ' . $this->url);
82
+            $this->log->warning('Skip : not a valid URL : '.$this->url);
83 83
             return null;
84 84
         }
85 85
         return $this->registrableDomain;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function hasForbiddenFilenameExtension(): bool
94 94
     {
95
-        return (bool)preg_match(
95
+        return (bool) preg_match(
96 96
             '#\.(pdf|jpg|jpeg|gif|png|webp|xls|xlsx|xlr|xml|xlt|txt|csv|js|docx|exe|gz|zip|ini|movie|mp3|mp4|ogg|raw|rss|tar|tgz|wma)$#i',
97 97
             $this->url
98 98
         );
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternPageFactory.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     public function fromURL(string $url, InternetDomainParserInterface $domainParser): ExternPage
31 31
     {
32 32
         if (!HttpUtil::isHttpURL($url)) {
33
-            throw new Exception('string is not an URL ' . $url);
33
+            throw new Exception('string is not an URL '.$url);
34 34
         }
35 35
 
36 36
         $html = $this->getHTML($url, true);
37 37
         if (empty($html)) {
38
-            throw new DomainException('No HTML from requested URL ' . $url);
38
+            throw new DomainException('No HTML from requested URL '.$url);
39 39
         }
40 40
 
41 41
         return new ExternPage($url, $html, new TagParser(), $domainParser, $this->log);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46)
55 55
         // checkdnsrr($string, "A") // check DNS record
56 56
         if (!HttpUtil::isHttpURL($url)) {
57
-            throw new DomainException('URL not compatible : ' . $url);
57
+            throw new DomainException('URL not compatible : '.$url);
58 58
         }
59 59
         $response = $this->client->get($url, [
60 60
             'timeout' => 20,
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         ]);
66 66
 
67 67
         if (200 !== $response->getStatusCode()) {
68
-            $this->log->error('[z49] HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase());
68
+            $this->log->error('[z49] HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase());
69 69
 
70 70
             return null;
71 71
         }
Please login to merge, or discard this patch.
src/Infrastructure/TorClientAdapter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         return null;
87 87
     }
88 88
 
89
-    public function get(string|UriInterface $uri, array $options = []): ResponseInterface
89
+    public function get(string | UriInterface $uri, array $options = []): ResponseInterface
90 90
     {
91 91
         if (isset($options['allow_redirects']) && $options['allow_redirects'] !== false) {
92 92
             $this->maxRedirects = self::DEFAULT_MAX_REDIRECTS;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * todo : add redirect http referer
100 100
      */
101
-    private function getRecursive(UriInterface|string $uri, array $options, int $loop = 0): ResponseInterface
101
+    private function getRecursive(UriInterface | string $uri, array $options, int $loop = 0): ResponseInterface
102 102
     {
103 103
         $response = $this->client->get($uri, $options);
104 104
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if ($response->getStatusCode() >= 300 && $response->getStatusCode() < 400) {
107 107
             $redirectUri = $response->getHeader('location')[0] ?? null;
108 108
             if ($loop >= $this->maxRedirects || !$redirectUri) {
109
-                throw new Exception('TorClientAdapter::get Error too many redirects ' . $response->getStatusCode());
109
+                throw new Exception('TorClientAdapter::get Error too many redirects '.$response->getStatusCode());
110 110
             }
111 111
             $loop++;
112 112
             return $this->getRecursive($redirectUri, $options, $loop);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
         // Error 4xx 5xx
116 116
         if ($response->getStatusCode() >= 400) {
117
-            throw new Exception($response->getStatusCode() . ' ' . $response->getReasonPhrase());
117
+            throw new Exception($response->getStatusCode().' '.$response->getReasonPhrase());
118 118
         }
119 119
 
120 120
         return $response;
Please login to merge, or discard this patch.
src/Infrastructure/GuzzleClientAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         );
41 41
     }
42 42
 
43
-    public function get(string|UriInterface $uri, array $options = []): ResponseInterface
43
+    public function get(string | UriInterface $uri, array $options = []): ResponseInterface
44 44
     {
45 45
         return $this->client->get($uri, $options);
46 46
     }
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
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 $summary = new Summary('test');
35 35
 
36 36
 $torEnabled = true;
37
-echo "TOR enabled : ".($torEnabled ? "oui" : "non"). "\n";
37
+echo "TOR enabled : ".($torEnabled ? "oui" : "non")."\n";
38 38
 
39 39
 $trans = new ExternRefTransformer(
40 40
     new ExternMapper($logger),
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     // Attention : pas de post-processing (sanitize title, etc.)
50 50
     $result = $trans->process($url, $summary);
51 51
 } catch (Exception $e) {
52
-    $result = "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine();
52
+    $result = "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine();
53 53
 }
54 54
 
55
-echo '>>> '. $result."\n";
55
+echo '>>> '.$result."\n";
56 56
 
57 57
 
58 58
 
Please login to merge, or discard this patch.