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

NewPageOuvrageToCompleteValidator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 13 4
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
}