Completed
Push — master ( 83639c...e6b957 )
by Alexpts
01:54
created

RequiredValidator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 16 7
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Validator\Validators;
5
6
class RequiredValidator
7
{
8 2
    public function __invoke($value): bool
9
    {
10 2
        if ($value === null) {
11 1
           return false;
12
        }
13
14 2
        if (is_string($value) && trim($value) === '') {
15 1
            return false;
16
        }
17
18 2
        if ((is_array($value) || $value instanceof \Countable) && count($value) < 1) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !((is_array($valu... && count($value) < 1);.
Loading history...
19 1
            return false;
20
        }
21
22 1
        return true;
23
    }
24
}
25