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

WithAnyCondition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isMet() 0 9 3
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
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
/**
18
 * Fires when any of listed values are not empty.
19
 */
20
final class WithAnyCondition extends AbstractCondition
21
{
22
    /**
23
     * @param ValidatorInterface $validator
24
     * @param string             $field
25
     * @param mixed              $value
26
     * @return bool
27
     */
28
    public function isMet(ValidatorInterface $validator, string $field, $value): bool
29
    {
30
        foreach ($this->options as $option) {
31
            if (!empty($validator->getValue($option))) {
32
                return true;
33
            }
34
        }
35
36
        return false;
37
    }
38
}
39