RequiredValidator::verdict()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 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 RequiredValidator extends RuleValidator
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 3
    public function verdict($value, Rule $rule): VerdictInterface
18
    {
19 3
        if (null !== $value) {
20 3
            return Verdict::passing($rule);
21
        }
22
23 2
        return Verdict::failing($rule);
24
    }
25
}
26