Total Complexity | 4 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | final class KeyValueTranslator implements Translator |
||
11 | { |
||
12 | /** |
||
13 | * @var array key value dictionary of translations |
||
14 | */ |
||
15 | private $dictionary; |
||
16 | |||
17 | private function __construct(array $dictionary) |
||
18 | { |
||
19 | Assert::allString(array_keys($dictionary)); |
||
20 | Assert::allString($dictionary); |
||
21 | |||
22 | $this->dictionary = $dictionary; |
||
23 | } |
||
24 | |||
25 | public static function withDictionary(array $dictionary): self |
||
26 | { |
||
27 | return new self($dictionary); |
||
28 | } |
||
29 | |||
30 | public function translate(string $string): string |
||
35 | } |
||
36 | } |
||
37 |