Passed
Branch dev3 (ae391d)
by Dispositif
02:29
created

CitationsNotEmptyValidator::__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 1
Metric Value
eloc 2
c 1
b 0
f 1
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
namespace App\Application\OuvrageEdit\Validators;
11
12
use DomainException;
13
use Psr\Log\LoggerInterface;
14
15
class CitationsNotEmptyValidator implements ValidatorInterface
16
{
17
    /**
18
     * @var array|null
19
     */
20
    protected $pageCitationCollection;
21
    protected $log;
22
23
    public function __construct(?array $pageCitationCollection, LoggerInterface $logger)
24
    {
25
        $this->pageCitationCollection = $pageCitationCollection;
26
        $this->log = $logger;
27
    }
28
29
    public function validate(): bool
30
    {
31
        if (empty($this->pageCitationCollection)) {
32
            $this->log->alert("SKIP : OuvrageEditWorker / getAllRowsToEdit() no row to process\n");
33
            sleep(60);
34
            throw new DomainException('no row to process');
35
        }
36
37
        return true;
38
    }
39
}