Passed
Push — dev ( 4ef148...eba0dc )
by Dispositif
07:17
created

RefGooWorker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitles() 0 10 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 RefGooWorker
17
 *
18
 * @package App\Application\Examples
19
 */
20
class RefGooWorker extends AbstractBotTaskWorker
21
{
22
    const TASK_NAME           = "bot : Amélioration bibliographique : lien Google Books ⇒ {ouvrage}"; // 😎
23
    const SLEEP_AFTER_EDITION = 20;
24
    protected $botFlag = true;
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/&formatversion=2&format=json&srnamespace=0'
33
            .'&srlimit=100&srqiprofile=popular_inclinks_pv&srsort=last_edit_desc';
34
35
        $this->pageListGenerator->setUrl($cirrusURL);
1 ignored issue
show
Bug introduced by
The method setUrl() does not exist on App\Infrastructure\PageListInterface. It seems like you code against a sub-type of App\Infrastructure\PageListInterface such as App\Infrastructure\CirrusSearch. ( Ignorable by Annotation )

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

35
        $this->pageListGenerator->/** @scrutinizer ignore-call */ 
36
                                  setUrl($cirrusURL);
Loading history...
36
37
        return $this->pageListGenerator->getPageTitles();
38
    }
39
40
    protected function processDomain(string $title, ?string $text): ?string
41
    {
42
        $ref = new RefGoogleBook();
43
44
        return $ref->process($text);
1 ignored issue
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

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