Passed
Branch dev3 (d976d5)
by Dispositif
02:50
created

GoogleRequestValidator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
11
namespace App\Application\OuvrageComplete\Validators;
12
13
14
use App\Domain\Models\Wiki\OuvrageTemplate;
15
16
class GoogleRequestValidator implements CompleteValidatorInterface
17
{
18
19
    /**
20
     * @var OuvrageTemplate
21
     */
22
    protected $ouvrage;
23
    /**
24
     * @var OuvrageTemplate|null
25
     */
26
    protected $bnfOuvrage;
27
28
    public function __construct(OuvrageTemplate $ouvrage, ?OuvrageTemplate $bnfOuvrage)
29
    {
30
        $this->ouvrage = $ouvrage;
31
        $this->bnfOuvrage = $bnfOuvrage;
32
    }
33
34
    public function validate(): bool
35
    {
36
        return !$this->bnfOuvrage instanceof OuvrageTemplate
37
            || !$this->bnfOuvrage->hasParamValue('titre')
38
            || (
39
                !$this->ouvrage->hasParamValue('lire en ligne')
40
                && !$this->ouvrage->hasParamValue('présentation en ligne')
41
            );
42
    }
43
}