Passed
Push — master ( 860b7e...86fe81 )
by Dispositif
03:31
created
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/InfrastructurePorts/HttpClientInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
 
15 15
 interface HttpClientInterface
16 16
 {
17
-    public function get(string|UriInterface $uri, array $options = []): ResponseInterface;
17
+    public function get(string | UriInterface $uri, array $options = []): ResponseInterface;
18 18
     public function request($method, $uri, array $options = []): ResponseInterface;
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
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.