Passed
Pull Request — master (#517)
by
unknown
02:46
created

NeverEmpty   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\EmptyCondition;
6
7
use Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait;
8
use Yiisoft\Validator\Validator;
9
10
/**
11
 * Empty condition is a callable returning `true` if a value must be considered empty.
12
 *
13
 * With `NeverEmpty` a value is always considered non-empty. With regard to validation process, a corresponding rule is
14
 * never skipped if `NeverEmpty` is set:
15
 *
16
 * - At a rule level via `$skipOnEmpty` property, but only for rules implementing {@see SkipOnEmptyTrait} / including
17
 * {@see SkipOnEmptyTrait}.
18
 * - At validator level ({@see Validator::$defaultSkipOnEmptyCondition}).
19
 *
20
 * This is a default behavior for all built-in rules.
21
 *
22
 * A shortcut for `new NeverEmpty()` is `false`.
23
 */
24
final class NeverEmpty
25
{
26
    /**
27
     * @param mixed $value The validated value.
28
     * @param bool $isAttributeMissing A flag defining whether the attribute is missing (not used / not passed at all).
29
     *
30
     * @return bool Whether the validated value is considered empty.
31
     */
32
    public function __invoke(mixed $value, bool $isAttributeMissing): bool
33
    {
34
        return false;
35
    }
36
}
37