@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class StatsSqlite3 implements StatsInterface |
20 | 20 | { |
21 | - protected const DEFAULT_FILEPATH = __DIR__ . '/../../../log/stats.db'; |
|
21 | + protected const DEFAULT_FILEPATH = __DIR__.'/../../../log/stats.db'; |
|
22 | 22 | protected const MAX_TAG_LENGTH = 100; |
23 | 23 | |
24 | 24 | protected SQLite3 $db; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // `num` default value is 1 so insert is enough to set num=1 |
76 | 76 | try { |
77 | 77 | return $this->sqliteExecWriteOrWait( |
78 | - 'INSERT INTO ' . $table . ' (tag) VALUES("' . $tag . '") ON CONFLICT(tag) DO UPDATE SET num=num+1' |
|
78 | + 'INSERT INTO '.$table.' (tag) VALUES("'.$tag.'") ON CONFLICT(tag) DO UPDATE SET num=num+1' |
|
79 | 79 | ); |
80 | 80 | } catch (Exception $e) { |
81 | 81 | return false; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $tag = $this->formatTag($tag); |
108 | 108 | try { |
109 | 109 | return $this->sqliteExecWriteOrWait( |
110 | - 'INSERT OR REPLACE INTO tagnum (tag,num) VALUES("' . $tag . '", ' . $num . ')' |
|
110 | + 'INSERT OR REPLACE INTO tagnum (tag,num) VALUES("'.$tag.'", '.$num.')' |
|
111 | 111 | ); |
112 | 112 | } catch (Exception $e) { |
113 | 113 | return false; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $tag = $this->formatTag($tag); |
120 | 120 | try { |
121 | 121 | return $this->sqliteExecWriteOrWait( |
122 | - 'INSERT INTO tagnum (tag) VALUES("' . $tag . '") ON CONFLICT(tag) DO UPDATE SET num=num-1' |
|
122 | + 'INSERT INTO tagnum (tag) VALUES("'.$tag.'") ON CONFLICT(tag) DO UPDATE SET num=num-1' |
|
123 | 123 | ); |
124 | 124 | } catch (Exception $e) { |
125 | 125 | return false; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | // use LoggerTrait; |
22 | 22 | |
23 | - protected const CRITICAL_LOG_PATH = __DIR__ . '/../../../log/critical.log'; |
|
23 | + protected const CRITICAL_LOG_PATH = __DIR__.'/../../../log/critical.log'; |
|
24 | 24 | public bool $verbose = false; |
25 | 25 | public bool $debug = false; |
26 | 26 | public bool $colorMode = false; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __call(string $method, array $args): void |
38 | 38 | { |
39 | - $this->notice('Call to undefined method ConsoleLogger:' . $method . '()'); |
|
39 | + $this->notice('Call to undefined method ConsoleLogger:'.$method.'()'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | case 'emergency': |
63 | 63 | case 'alert': |
64 | 64 | case 'critical': |
65 | - $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_RED . Color::WHITE); |
|
65 | + $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_RED.Color::WHITE); |
|
66 | 66 | if ($context !== []) { |
67 | 67 | dump($context); |
68 | 68 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | break; |
71 | 71 | case 'error': |
72 | 72 | case 'warning': |
73 | - $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_YELLOW . Color::BLACK); |
|
73 | + $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_YELLOW.Color::BLACK); |
|
74 | 74 | if ($context !== []) { |
75 | 75 | dump($context); |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'notice': |
79 | - $this->echoColor("[$level] " . $message . "\n"); |
|
79 | + $this->echoColor("[$level] ".$message."\n"); |
|
80 | 80 | if ($context !== []) { |
81 | 81 | dump($context); |
82 | 82 | } |
83 | 83 | break; |
84 | 84 | case 'info': |
85 | 85 | if ($this->verbose || $this->debug) { |
86 | - $this->echoColor("[$level] " . $message . "\n", Color::GRAY); |
|
86 | + $this->echoColor("[$level] ".$message."\n", Color::GRAY); |
|
87 | 87 | if ($context !== []) { |
88 | 88 | dump($context); |
89 | 89 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | break; |
92 | 92 | case 'debug': |
93 | 93 | if ($this->debug) { |
94 | - $this->echoColor("[$level] " . $message . "\n", Color::GRAY); |
|
94 | + $this->echoColor("[$level] ".$message."\n", Color::GRAY); |
|
95 | 95 | if ($context !== []) { |
96 | 96 | dump($context); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 'echo': |
101 | - $this->echoColor($message . "\n"); |
|
101 | + $this->echoColor($message."\n"); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | private function echoColor(string $text, ?string $color = null): void |
122 | 122 | { |
123 | 123 | if ($this->colorMode && !empty($color)) { |
124 | - echo $color . $text . Color::NORMAL; |
|
124 | + echo $color.$text.Color::NORMAL; |
|
125 | 125 | |
126 | 126 | return; |
127 | 127 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | file_put_contents( |
134 | 134 | self::CRITICAL_LOG_PATH, |
135 | - date('d-m-Y H:i:s') . " : $level : " . $message . PHP_EOL, |
|
135 | + date('d-m-Y H:i:s')." : $level : ".$message.PHP_EOL, |
|
136 | 136 | FILE_APPEND |
137 | 137 | ); |
138 | 138 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | $this->url = $url; |
50 | 50 | $this->registrableDomain = null; |
51 | 51 | if (!HttpUtil::isHttpURL($url)) { |
52 | - $this->log->debug('Skip : not Http URL : ' . $url, ['stats' => 'externref.skip.notRawURL']); |
|
52 | + $this->log->debug('Skip : not Http URL : '.$url, ['stats' => 'externref.skip.notRawURL']); |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($this->hasForbiddenFilenameExtension()) { |
57 | - $this->log->debug('Skip : ForbiddenFilenameExtension : ' . $url, ['stats' => 'externref.skip.forbiddenFilenameExtension']); |
|
57 | + $this->log->debug('Skip : ForbiddenFilenameExtension : '.$url, ['stats' => 'externref.skip.forbiddenFilenameExtension']); |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function hasForbiddenFilenameExtension(): bool |
72 | 72 | { |
73 | - return (bool)preg_match( |
|
73 | + return (bool) preg_match( |
|
74 | 74 | '#\.(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', |
75 | 75 | $this->url |
76 | 76 | ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | try { |
82 | 82 | $this->registrableDomain = $this->internetDomainParser->getRegistrableDomainFromURL($this->url); |
83 | 83 | } catch (Exception) { |
84 | - $this->log->warning('Skip : registrableDomain not a valid URL : ' . $this->url, |
|
84 | + $this->log->warning('Skip : registrableDomain not a valid URL : '.$this->url, |
|
85 | 85 | ['stats' => 'externref.skip.URLAuthorized.exception2'] |
86 | 86 | ); |
87 | 87 | return null; |
@@ -35,13 +35,13 @@ discard block |
||
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; |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | } |
97 | 97 | $this->registrableDomain = $this->urlChecker->getRegistrableDomain($url); // hack |
98 | 98 | if ($this->isSiteBlackListed()) { |
99 | - $this->log->debug('Site blacklisted : ' . $this->registrableDomain, ['stats' => 'externref.skip.blacklisted']); |
|
99 | + $this->log->debug('Site blacklisted : '.$this->registrableDomain, ['stats' => 'externref.skip.blacklisted']); |
|
100 | 100 | return $url; |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ($this->registrableDomain && !$this->validateConfigWebDomain($this->registrableDomain)) { |
104 | 104 | $this->log->debug( |
105 | - 'Domain blocked by config : ' . $this->registrableDomain, |
|
105 | + 'Domain blocked by config : '.$this->registrableDomain, |
|
106 | 106 | ['stats' => 'externref.skip.domainDisabledByConfig'] |
107 | 107 | ); |
108 | 108 | return $url; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | protected function isSiteBlackListed(): bool |
160 | 160 | { |
161 | 161 | if ($this->registrableDomain && $this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) { |
162 | - $this->log->notice("Skip web site " . $this->registrableDomain); |
|
162 | + $this->log->notice("Skip web site ".$this->registrableDomain); |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | return false; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : []; |
178 | 178 | |
179 | 179 | if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) { |
180 | - $this->log->info("Domain " . $domain . " disabled\n"); |
|
180 | + $this->log->info("Domain ".$domain." disabled\n"); |
|
181 | 181 | |
182 | 182 | return false; |
183 | 183 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | protected function logDebugConfigWebDomain(string $domain): void |
189 | 189 | { |
190 | 190 | if (!isset($this->config[$domain])) { |
191 | - $this->log->debug("Domain " . $domain . " non configuré"); |
|
191 | + $this->log->debug("Domain ".$domain." non configuré"); |
|
192 | 192 | } else { |
193 | - $this->log->debug("Domain " . $domain . " configuré"); |
|
193 | + $this->log->debug("Domain ".$domain." configuré"); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if ($pageData === [] |
217 | 217 | || (empty($pageData['JSON-LD']) && empty($pageData['meta'])) |
218 | 218 | ) { |
219 | - $this->log->notice('No metadata : ' . $url); |
|
219 | + $this->log->notice('No metadata : '.$url); |
|
220 | 220 | |
221 | 221 | return true; |
222 | 222 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function emptyMapData(array $mapData, string $url): bool |
232 | 232 | { |
233 | 233 | if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) { |
234 | - $this->log->info('Mapping incomplet : ' . $url); |
|
234 | + $this->log->info('Mapping incomplet : '.$url); |
|
235 | 235 | |
236 | 236 | return true; |
237 | 237 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | protected function correctSiteViaWebarchiver(array $mapData): array |
323 | 323 | { |
324 | 324 | if (!empty($this->options['originalRegistrableDomain']) && $mapData['site']) { |
325 | - $mapData['site'] = $this->options['originalRegistrableDomain'] . ' via ' . $mapData['site']; |
|
325 | + $mapData['site'] = $this->options['originalRegistrableDomain'].' via '.$mapData['site']; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return $mapData; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $templateOptimized = $optimizer->getOptiTemplate(); |
347 | 347 | |
348 | 348 | $serialized = $templateOptimized->serialize(true); |
349 | - $this->log->info('Serialized 444: ' . $serialized . "\n"); |
|
349 | + $this->log->info('Serialized 444: '.$serialized."\n"); |
|
350 | 350 | return $serialized; |
351 | 351 | } |
352 | 352 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | { |
355 | 355 | $template = WikiTemplateFactory::create($templateName); |
356 | 356 | $template->userSeparator = " |"; |
357 | - $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0); |
|
357 | + $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0); |
|
358 | 358 | |
359 | 359 | return $template; |
360 | 360 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | protected HttpClientInterface $client; |
25 | 25 | |
26 | - public function __construct(private readonly LoggerInterface|NullLogger $log = new NullLogger()) |
|
26 | + public function __construct(private readonly LoggerInterface | NullLogger $log = new NullLogger()) |
|
27 | 27 | { |
28 | 28 | $this->client = ServiceFactory::getHttpClient(); |
29 | 29 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | { |
39 | 39 | $url = 'http://wikipedia.ramselehof.de/wikiblame.php?project=wikipedia&article=' |
40 | 40 | . str_replace(' ', '+', $article) |
41 | - . '&needle=' . urlencode($string) |
|
41 | + . '&needle='.urlencode($string) |
|
42 | 42 | . '&lang=fr&limit=2000&offjahr=2024&offmon=1&offtag=1&offhour=23&offmin=55' |
43 | 43 | . '&searchmethod=int&order=desc' |
44 | - . '&force_wikitags=' . ($hasWikicode ? 'on' : 'off') |
|
44 | + . '&force_wikitags='.($hasWikicode ? 'on' : 'off') |
|
45 | 45 | . '&user_lang=fr&ignorefirst=0'; |
46 | 46 | |
47 | 47 | $response = $this->client->get($url); |
48 | 48 | |
49 | 49 | if ($response->getStatusCode() !== 200) { |
50 | - $this->log->warning('WikiBlame: ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
50 | + $this->log->warning('WikiBlame: '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
51 | 51 | return null; |
52 | 52 | } |
53 | 53 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | return [ |
71 | - 'versionid' => (int)$matches[1], |
|
71 | + 'versionid' => (int) $matches[1], |
|
72 | 72 | 'dateraw' => $matches[2], |
73 | 73 | 'datetime' => DateUtil::simpleFrench2object($matches[2]), |
74 | 74 | ]; |
@@ -54,7 +54,7 @@ discard block |
||
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 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | '//script[@type="application/ld+json"]' |
95 | 95 | ); |
96 | 96 | } catch (Exception $e) { |
97 | - $this->log->warning('TagParser->xpathResults NULL ' . $this->url); |
|
97 | + $this->log->warning('TagParser->xpathResults NULL '.$this->url); |
|
98 | 98 | |
99 | 99 | return []; |
100 | 100 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | try { |
178 | 178 | if (!HttpUtil::isHttpURL($this->url)) { |
179 | - throw new Exception('string is not an URL ' . $this->url); |
|
179 | + throw new Exception('string is not an URL '.$this->url); |
|
180 | 180 | } |
181 | 181 | if (!$this->domainParser instanceof InternetDomainParserInterface) { |
182 | 182 | $this->log->notice('InternetDomainParser is not set'); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this->domainParser->getRegistrableDomainFromURL($this->url); |
188 | 188 | } catch (Exception $e) { |
189 | 189 | if ($this->log !== null) { |
190 | - $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL ' . $this->url); |
|
190 | + $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL '.$this->url); |
|
191 | 191 | } |
192 | 192 | throw new Exception('InternetDomainParser->getRegistrableDomainFromURL NULL', $e->getCode(), $e); |
193 | 193 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $first = mb_strtoupper(mb_substr($str, 0, 1, $e), $e); |
103 | 103 | $rest = mb_substr($str, 1, mb_strlen($str, $e), $e); |
104 | 104 | |
105 | - return $first . $rest; |
|
105 | + return $first.$rest; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $first = mb_strtolower(mb_substr($str, 0, 1, $e), $e); |
116 | 116 | $rest = mb_substr($str, 1, mb_strlen($str, $e), $e); |
117 | 117 | |
118 | - return $first . $rest; |
|
118 | + return $first.$rest; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | public static function replaceNonBreakingSpaces(string $text): string |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function trim(string $string): string |
130 | 130 | { |
131 | - return trim($string, self::NO_BREAK_SPACE . self::NO_BREAK_THIN_SPACE . "\n\t\r"); |
|
131 | + return trim($string, self::NO_BREAK_SPACE.self::NO_BREAK_THIN_SPACE."\n\t\r"); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | if (mb_strlen($text) > $maxLength) { |
255 | 255 | $spacePos = mb_strrpos(mb_substr($text, 0, $maxLength), ' '); |
256 | 256 | $spacePos = ($spacePos > ($maxLength - 12)) ? $spacePos : $maxLength; |
257 | - $text = trim(mb_substr($text, 0, $spacePos)) . self::SYMBOL_TEXT_CUT; |
|
257 | + $text = trim(mb_substr($text, 0, $spacePos)).self::SYMBOL_TEXT_CUT; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return $text; |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | $refsData = $this->extractAllGoogleRefs($text); |
63 | - $this->logger->debug('GoogleTransformer: refs found: ' . count($refsData)); |
|
63 | + $this->logger->debug('GoogleTransformer: refs found: '.count($refsData)); |
|
64 | 64 | if ($refsData !== []) { |
65 | 65 | $text = $this->processRef($text, $refsData); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $links = $this->extractGoogleExternalBullets($text); |
69 | - $this->logger->debug('GoogleTransformer: links found: ' . count($links)); |
|
69 | + $this->logger->debug('GoogleTransformer: links found: '.count($links)); |
|
70 | 70 | if ($links !== []) { |
71 | 71 | $text = $this->processExternLinks($text, $links); |
72 | 72 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // <ref>...</ref> or {{ref|...}} |
88 | 88 | // GoogleLivresTemplate::GOOGLEBOOK_URL_PATTERN |
89 | 89 | if (preg_match_all( |
90 | - '#(?:<ref[^>]*>|{{ref\|) ?(' . GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN . '[^>\]} \n]+) ?(?:</ref>|}})#i', |
|
90 | + '#(?:<ref[^>]*>|{{ref\|) ?('.GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN.'[^>\]} \n]+) ?(?:</ref>|}})#i', |
|
91 | 91 | $text, |
92 | 92 | $matches, |
93 | 93 | PREG_SET_ORDER |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function processRef(string $text, array $refsData): string |
103 | 103 | { |
104 | 104 | foreach ($refsData as $ref) { |
105 | - $this->logger->info('Process GoogleBooks ref: ' . $ref[1]); |
|
105 | + $this->logger->info('Process GoogleBooks ref: '.$ref[1]); |
|
106 | 106 | if ($this->quota->isQuotaReached()) { |
107 | 107 | $this->logger->debug('Quota Google atteint'); |
108 | 108 | throw new DomainException('Quota Google atteint'); |
@@ -111,19 +111,19 @@ discard block |
||
111 | 111 | $citation = $this->convertGBurl2OuvrageCitation(WikiTextUtil::stripFinalPoint($ref[1])); |
112 | 112 | sleep(2); |
113 | 113 | } catch (Throwable $e) { |
114 | - $this->logger->debug("Exception " . $e->getMessage()); |
|
114 | + $this->logger->debug("Exception ".$e->getMessage()); |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // ajout point final pour référence |
119 | 119 | $citation .= '.'; |
120 | 120 | |
121 | - $newRef = str_replace($ref[1], $citation, (string)$ref[0]); |
|
121 | + $newRef = str_replace($ref[1], $citation, (string) $ref[0]); |
|
122 | 122 | $this->logger->info($newRef); |
123 | 123 | |
124 | 124 | $text = str_replace($ref[0], $newRef, $text); |
125 | 125 | |
126 | - $this->logger->notice("sleep " . self::SLEEP_GOOGLE_API_INTERVAL); |
|
126 | + $this->logger->notice("sleep ".self::SLEEP_GOOGLE_API_INTERVAL); |
|
127 | 127 | sleep(self::SLEEP_GOOGLE_API_INTERVAL); |
128 | 128 | } |
129 | 129 | |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | // Google page => 'passage' |
178 | 178 | if (!empty($gooDat['pg'])) { |
179 | 179 | // Exclusion de page=1, page=2 (vue par défaut sur Google Book) |
180 | - if (preg_match('#(?:PA|PT)(\d+)$#', (string)$gooDat['pg'], $matches) && (int)$matches[1] >= 3) { |
|
180 | + if (preg_match('#(?:PA|PT)(\d+)$#', (string) $gooDat['pg'], $matches) && (int) $matches[1] >= 3) { |
|
181 | 181 | $page = $matches[1]; |
182 | 182 | } |
183 | 183 | // conversion chiffres Romain pour PR |
184 | 184 | // Exclusion de page=1, page=2 (vue par défaut sur Google Book) |
185 | - if (preg_match('#PR(\d+)$#', (string)$gooDat['pg'], $matches) && (int)$matches[1] >= 3) { |
|
186 | - $page = NumberUtil::arab2roman((int)$matches[1], true); |
|
185 | + if (preg_match('#PR(\d+)$#', (string) $gooDat['pg'], $matches) && (int) $matches[1] >= 3) { |
|
186 | + $page = NumberUtil::arab2roman((int) $matches[1], true); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | if (!empty($page)) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | // match "* https://books.google.fr/..." |
246 | 246 | if (preg_match_all( |
247 | - '#^\* *(' . GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN . '[^ <{\]}\n\r]+) *$#im', |
|
247 | + '#^\* *('.GoogleBooksUtil::GOOGLEBOOKS_START_URL_PATTERN.'[^ <{\]}\n\r]+) *$#im', |
|
248 | 248 | $text, |
249 | 249 | $matches, |
250 | 250 | PREG_SET_ORDER |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * @return string|string[] |
262 | 262 | * @throws Throwable |
263 | 263 | */ |
264 | - protected function processExternLinks(string $text, array $links): string|array |
|
264 | + protected function processExternLinks(string $text, array $links): string | array |
|
265 | 265 | { |
266 | 266 | foreach ($links as $pattern) { |
267 | - $this->logger->info('Process links: ' . $pattern[1]); |
|
267 | + $this->logger->info('Process links: '.$pattern[1]); |
|
268 | 268 | if ($this->quota->isQuotaReached()) { |
269 | 269 | $this->logger->debug('Quota Google atteint'); |
270 | 270 | throw new DomainException('Quota Google atteint'); |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | try { |
273 | 273 | $citation = $this->convertGBurl2OuvrageCitation(WikiTextUtil::stripFinalPoint($pattern[1])); |
274 | 274 | } catch (Exception $e) { |
275 | - $this->logger->debug("Exception " . $e->getMessage()); |
|
275 | + $this->logger->debug("Exception ".$e->getMessage()); |
|
276 | 276 | continue; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // todo : ajout point final pour référence ??? |
280 | 280 | $citation .= '.'; |
281 | 281 | |
282 | - $newRef = str_replace($pattern[1], $citation, (string)$pattern[0]); |
|
282 | + $newRef = str_replace($pattern[1], $citation, (string) $pattern[0]); |
|
283 | 283 | $this->logger->info($newRef); |
284 | 284 | |
285 | 285 | $text = str_replace($pattern[0], $newRef, $text); |
286 | 286 | |
287 | - $this->logger->info("Sleep " . self::SLEEP_GOOGLE_API_INTERVAL); |
|
287 | + $this->logger->info("Sleep ".self::SLEEP_GOOGLE_API_INTERVAL); |
|
288 | 288 | sleep(self::SLEEP_GOOGLE_API_INTERVAL); |
289 | 289 | } |
290 | 290 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public const SRQIPROFILE_DEFAULT = 'engine_autoselect'; |
39 | 39 | |
40 | 40 | protected const BASE_URL = 'https://fr.wikipedia.org/w/api.php'; // todo move config |
41 | - protected const CONTINUE_OFFSET_FILENAME = __DIR__ . '/../../resources/cirrusSearch-{HASH}.txt'; // todo move config |
|
41 | + protected const CONTINUE_OFFSET_FILENAME = __DIR__.'/../../resources/cirrusSearch-{HASH}.txt'; // todo move config |
|
42 | 42 | |
43 | 43 | protected array $requestParams = []; |
44 | 44 | protected array $defaultParams |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if ($this->options[self::OPTION_CONTINUE] ?? false) { |
73 | 73 | $continueOffset = 0; |
74 | 74 | if (!empty($arrayResp['continue']['sroffset'])) { |
75 | - $continueOffset = (int)$arrayResp['continue']['sroffset']; |
|
75 | + $continueOffset = (int) $arrayResp['continue']['sroffset']; |
|
76 | 76 | } |
77 | 77 | $this->saveOffsetInFile($continueOffset); |
78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $titles = []; |
86 | 86 | foreach ($results as $res) { |
87 | 87 | if (!empty($res['title'])) { |
88 | - $titles[] = trim((string)$res['title']); // trim utile ? |
|
88 | + $titles[] = trim((string) $res['title']); // trim utile ? |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | if ($response->getStatusCode() !== 200) { |
117 | 117 | throw new Exception( |
118 | - 'CirrusSearch error : ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase() |
|
118 | + 'CirrusSearch error : '.$response->getStatusCode().' '.$response->getReasonPhrase() |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | $json = $response->getBody()->getContents(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | return []; |
124 | 124 | } |
125 | 125 | try { |
126 | - $array = json_decode((string)$json, true, 512, JSON_THROW_ON_ERROR); |
|
126 | + $array = json_decode((string) $json, true, 512, JSON_THROW_ON_ERROR); |
|
127 | 127 | } catch (Throwable $e) { |
128 | 128 | throw new Exception($e->getMessage(), $e->getCode(), $e); |
129 | 129 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // RFC3986 : space => %20 |
146 | 146 | $query = http_build_query($this->requestParams, 'bla', '&', PHP_QUERY_RFC3986); |
147 | 147 | |
148 | - return self::BASE_URL . '?' . $query; |
|
148 | + return self::BASE_URL.'?'.$query; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | protected function getOffsetFromFile(array $allParams): int |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | return 0; |
157 | 157 | } |
158 | 158 | |
159 | - return (int)trim(file_get_contents($file)); |
|
159 | + return (int) trim(file_get_contents($file)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | protected function hashSearchParams(array $params): string |