Completed
Push — master ( 0f709d...dd560f )
by Albert
17:45 queued 07:45
created

NotBlankValidator::verdict()   B

Complexity

Conditions 5
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 8.8571
cc 5
eloc 9
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Albert221\Validation\Rule;
6
7
use Albert221\Validation\Rule;
8
use Albert221\Validation\RuleValidator;
9
use Albert221\Validation\Verdict;
10
use Albert221\Validation\VerdictInterface;
11
12
class NotBlankValidator extends RuleValidator
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function verdict($value, Rule $rule): VerdictInterface
18
    {
19
        if (is_null($value)) {
20
            return Verdict::create(true, $rule);
21
        }
22
23
        return Verdict::create(
24
            !empty($value)
25
                || $value === "0"
26
                || $value === 0
27
                || $value === false,
28
            $rule
29
        );
30
    }
31
}
32