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

RequiredValidator::__invoke()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 8
nc 4
nop 1
crap 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