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

NewPageOuvrageToCompleteValidator::validate()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 10
cc 4
nc 2
nop 0
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
namespace App\Application\OuvrageComplete\Validators;
11
12
use App\Domain\Models\PageOuvrageDTO;
13
14
class NewPageOuvrageToCompleteValidator implements CompleteValidatorInterface
15
{
16
    /**
17
     * @var PageOuvrageDTO|null
18
     */
19
    protected $pageOuvrage;
20
21
    public function __construct(?PageOuvrageDTO $pageOuvrage)
22
    {
23
        $this->pageOuvrage = $pageOuvrage;
24
    }
25
26
    public function validate(): bool
27
    {
28
        if (
29
            !$this->pageOuvrage instanceof PageOuvrageDTO
30
            || empty($this->pageOuvrage->getRaw())
31
            || !empty($this->pageOuvrage->getOpti())
32
        ) {
33
            echo "STOP: NewPageOuvrageToCompleteValidator \n";
34
35
            return false;
36
        }
37
38
        return true;
39
    }
40
}