Passed
Push — master ( 893d1e...31005e )
by Kirill
03:35
created

NoneOfCondition   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isMet() 0 9 3
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license MIT
7
 * @author  Valentin Vintsukevich (vvval)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Validation\Condition;
13
14
use Spiral\Validation\AbstractCondition;
15
use Spiral\Validation\ValidatorInterface;
16
17
class NoneOfCondition extends AbstractCondition
18
{
19
    /** @var Compositor */
20
    private $compositor;
21
22
    /**
23
     * @param Compositor $compositor
24
     */
25
    public function __construct(Compositor $compositor)
26
    {
27
        $this->compositor = $compositor;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function isMet(ValidatorInterface $validator, string $field, $value): bool
34
    {
35
        foreach ($this->compositor->makeConditions($field, $this->options) as $condition) {
36
            if ($condition->isMet($validator, $field, $value)) {
37
                return false;
38
            }
39
        }
40
41
        return true;
42
    }
43
}
44