Completed
Pull Request — master (#7)
by Albert
02:45
created

RequiredValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 14
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A verdict() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Albert221\Validation\Rule;
6
7
use Albert221\Validation\Verdict;
8
use Albert221\Validation\VerdictInterface;
9
10
class RequiredValidator extends RuleValidator
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 2
    public function verdict($value, Rule $rule): VerdictInterface
16
    {
17 2
        if (null !== $value) {
18 2
            return Verdict::create(true, $rule);
19
        }
20
21 1
        return Verdict::create(false, $rule);
22
    }
23
}
24