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

MaxValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 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