Completed
Push — master ( 977461...e97616 )
by Magnar Ovedal
08:19 queued 05:37
created

MixedCaseMap::getMap()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 1
dl 0
loc 14
ccs 9
cts 9
cp 1
crap 3
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
10
final class MixedCaseMap implements CodeMap
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15 1
    public function getMap(CharTree $charTree): array
16
    {
17 1
        $codeMap = [];
18 1
        foreach ($charTree->getTreeTrimmedToLength(1) as $char) {
19 1
            $lowerCase = mb_strtolower($char);
20 1
            $upperCase = mb_strtoupper($char);
21
22 1
            $codeMap[$char] = [$lowerCase];
23
24 1
            if ($lowerCase !== $upperCase) {
25 1
                $codeMap[$char][] = $upperCase;
26
            }
27
        }
28 1
        return $codeMap;
29
    }
30
}
31