Completed
Push — master ( 974273...f24470 )
by Magnar Ovedal
37:37 queued 31:22
created

UpperCaseMap::getMap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
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 UpperCaseMap implements CodeMap
13
{
14
    /**
15
     * @var Truncator Formatter for extracting the first character.
16
     */
17
    private $charExtractor;
18
19 3
    public function __construct()
20
    {
21 3
        $this->charExtractor = new Truncator(1);
22 3
        $this->charExtractor->setNext(new LengthFilter(1, 1));
23 3
    }
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_strtoupper($char)];
33
        }
34 3
        return $codeMap;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function getLengths(): array
41
    {
42
        return [1];
43
}
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected EOF, expecting T_FUNCTION or T_CONST on line 43 at column 0
Loading history...
44