MaxValidator::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

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