Completed
Push — master ( 5e2eb6...86efd8 )
by Magnar Ovedal
34:31 queued 29:45
created

LowerCaseMap   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 39
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMap() 0 7 2
A __construct() 0 4 1
A getLengths() 0 3 1
A code() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice\CodeMap;
6
7
use Stadly\PasswordPolice\CharTree;
8
use Stadly\PasswordPolice\CodeMap;
9
use Stadly\PasswordPolice\Formatter\LengthFilter;
10
use Stadly\PasswordPolice\Formatter\Truncator;
11
12
final class LowerCaseMap implements CodeMap
13
{
14
    /**
15
     * @var Truncator Formatter for extracting the first character.
16
     */
17
    private $charExtractor;
18
19 11
    public function __construct()
20
    {
21 11
        $this->charExtractor = new Truncator(1);
22 11
        $this->charExtractor->setNext(new LengthFilter(1, 1));
23 11
    }
24
25
    /**
26
     * {@inheritDoc}
27
     */
28 3
    public function getMap(CharTree $charTree): array
29
    {
30 3
        $codeMap = [];
31 3
        foreach ($this->charExtractor->apply($charTree) as $char) {
32 1
            $codeMap[$char] = [mb_strtolower($char)];
33
        }
34 3
        return $codeMap;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 1
    public function getLengths(): array
41
    {
42 1
        return [1];
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 7
    public function code(string $string): array
49
    {
50 7
        return [mb_strtolower($string)];
51
    }
52
}
53