Passed
Push — master ( ba420a...c7e687 )
by Magnar Ovedal
02:56
created

LeetspeakDecoder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A applyCurrent() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice\Formatter;
6
7
use Stadly\PasswordPolice\CharTree;
8
use Stadly\PasswordPolice\CodeMap\LeetspeakMap;
9
use Stadly\PasswordPolice\Formatter;
10
11
final class LeetspeakDecoder implements Formatter
12
{
13
    use Chaining;
14
15
    /**
16
     * @var Coder Leetspeak coder.
17
     */
18
    private $leetspeakCoder;
19
20 4
    public function __construct()
21
    {
22 4
        $this->leetspeakCoder = new Coder(new LeetspeakMap());
23 4
    }
24
25
    /**
26
     * @param CharTree $charTree Character tree to format.
27
     * @return CharTree Leetspeak decoded variant of the character tree.
28
     */
29 4
    protected function applyCurrent(CharTree $charTree): CharTree
30
    {
31 4
        return $this->leetspeakCoder->apply($charTree);
32
    }
33
}
34