Total Complexity | 5 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class AsciiString implements StringInterface |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $text; |
||
20 | |||
21 | 5 | public function __construct(string $text) |
|
24 | 5 | } |
|
25 | |||
26 | /** |
||
27 | * @return array |
||
28 | * @psalm-return array<int, int> |
||
29 | * @psalm-pure |
||
30 | */ |
||
31 | 3 | public function asCharacters(): array |
|
32 | { |
||
33 | 3 | return '' == $this->text |
|
34 | 1 | ? [] |
|
35 | 3 | : array_map('ord', str_split($this->text)); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return string |
||
40 | * @psalm-pure |
||
41 | */ |
||
42 | 1 | public function asAscii(): string |
|
43 | { |
||
44 | 1 | return $this->text; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | * @psalm-pure |
||
50 | */ |
||
51 | 1 | public function asUtf8(): string |
|
54 | } |
||
55 | } |
||
56 |