Passed
Branch dev (6bb8f6)
by Dispositif
03:01
created

GooRefWorker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitles() 0 11 1
A processDomain() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of dispositif/wikibot application
5
 * 2019 : Philippe M. <[email protected]>
6
 * For the full copyright and MIT license information, please view the LICENSE file.
7
 */
8
declare(strict_types=1);
9
10
namespace App\Application\Examples;
11
12
use App\Application\AbstractBotTaskWorker;
13
use App\Domain\RefGoogleBook;
14
15
/**
16
 * Class GooRefWorker
17
 *
18
 * @package App\Application\Examples
19
 */
20
class GooRefWorker extends AbstractBotTaskWorker
21
{
22
    const TASK_NAME           = "Amélioration bibliographique : lien Google Books ⇒ {ouvrage}"; // 😎
23
    const SLEEP_AFTER_EDITION = 20;
24
    protected $botFlag = false;
25
26
    protected $modeAuto = true;
27
28
    protected function getTitles(): array
29
    {
30
        $cirrusURL
31
            = 'https://fr.wikipedia.org/w/api.php?action=query&list=search'
32
            .'&srsearch=%22https://books.google%22%20insource:/\%3Cref[^\%3E]*\%3Ehttps\:\/\/books\.google/'
33
            .'&formatversion=2&format=json&srnamespace=0'
34
            .'&srlimit=100&srqiprofile=popular_inclinks_pv&srsort=last_edit_desc';
35
//            .'&srlimit=100&srsort=random';
36
        $this->pageListGenerator->setUrl($cirrusURL);
37
38
        return $this->pageListGenerator->getPageTitles();
39
    }
40
41
    protected function processDomain(string $title, ?string $text): ?string
42
    {
43
        $ref = new RefGoogleBook();
44
45
        return $ref->process($text);
0 ignored issues
show
Bug introduced by
It seems like $text can also be of type null; however, parameter $text of App\Domain\RefGoogleBook::process() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
        return $ref->process(/** @scrutinizer ignore-type */ $text);
Loading history...
46
    }
47
}
48
49
50
51
52
53
54
55
56