Completed
Push — master ( 9e7056...a5af75 )
by Alexpts
02:28
created

MaxValidator::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
crap 3
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\Validator\Validators;
5
6
class MaxValidator
7
{
8 9
    public function __invoke($value, int $max): bool
9
    {
10 9
        if (is_numeric($value)) {
11 3
            return $value <= $max;
12
        }
13
14 6
        if (is_array($value)) {
15 3
            return count($value) <= $max;
16
        }
17
18 3
        return mb_strlen($value) <= $max;
19
    }
20
}
21