MaxLength   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 2
c 1
b 0
f 0
dl 0
loc 14
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isValid() 0 3 1
A getMessages() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Form\Validator;
6
7
use function strlen;
8
9
class MaxLength implements ValidatorInterface
10
{
11 2
    public function __construct(
12
        private int $maxLength
13 2
    ) {}
14
15 2
    public function isValid(mixed $value): bool
16
    {
17 2
        return strlen($value) <= $this->maxLength;
18
    }
19
20 1
    public function getMessages(): array
21
    {
22 1
        return ['Exceeded maximum length of ' . $this->maxLength];
23
    }
24
}
25