Passed
Push — master ( 911a0c...eea5e3 )
by Derek Stephen
02:48 queued 01:01
created

MinLength   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessages() 0 3 1
A isValid() 0 3 1
A __construct() 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 MinLength implements ValidatorInterface
10
{
11 1
    public function __construct(
12
        private int $minLength
13 1
    ) {}
14
15 1
    public function isValid(mixed $value): bool
16
    {
17 1
        return strlen($value) >= $this->minLength;
18
    }
19
20
    public function getMessages(): array
21
    {
22
        return ['Minimum length must be ' . $this->minLength];
23
    }
24
}
25