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

WithAnyCondition::isMet()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 3
nc 3
nop 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