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

NotBlankValidator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B verdict() 0 14 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
    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