NotBlankValidator::verdict()   B
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 2
nop 2
crap 5
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 1
    public function verdict($value, Rule $rule): VerdictInterface
18
    {
19 1
        if (is_null($value)) {
20 1
            return Verdict::passing($rule);
21
        }
22
23 1
        return Verdict::create(
24 1
            !empty($value)
25 1
                || $value === "0"
26 1
                || $value === 0
27 1
                || $value === false,
28 1
            $rule
29
        );
30
    }
31
}
32