Completed
Push — master ( bcf360...98d48e )
by Abdala
03:37
created

Lowercase::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CustomerGauge\Password\Rule;
6
7
use CustomerGauge\Password\Exception\InvalidCharacterType;
8
use CustomerGauge\Password\Rule;
9
use function count;
10
use function preg_match;
11
12
final class Lowercase implements Rule
13
{
14
    /** @var int */
15
    private $count;
16
17 2
    public function __construct(int $count = 1)
18
    {
19 2
        $this->count = $count;
20 2
    }
21
22 2
    public function __invoke(string $password) : void
23
    {
24 2
        preg_match('/[a-z]/', $password, $matches);
25
26 2
        if (count($matches) < $this->count) {
27 2
            throw InvalidCharacterType::requires('lowercase', $this->count, count($matches));
28
        }
29
    }
30
}
31