Total Complexity | 7 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class Text extends AEncoder |
||
15 | { |
||
16 | const DATA_SEPARATOR = ':'; |
||
17 | const LINE_SEPARATOR = "\r\n"; |
||
18 | |||
19 | 1 | public function unpack(string $content): Data |
|
20 | { |
||
21 | 1 | $lines = explode(static::LINE_SEPARATOR, $content); |
|
22 | 1 | $libData = new Data(); |
|
23 | 1 | if (false !== $lines) { |
|
24 | 1 | foreach ($lines as $line) { |
|
25 | 1 | if (0 < mb_strlen($line)) { |
|
26 | 1 | $data = explode(static::DATA_SEPARATOR, $line); |
|
27 | 1 | if (false !== $data) { |
|
28 | 1 | list($key, $value, $nothing) = $data; |
|
29 | 1 | $libData->{$key} = $value; |
|
30 | } |
||
31 | } |
||
32 | } |
||
33 | } |
||
34 | 1 | return $libData->clear(); |
|
35 | } |
||
36 | |||
37 | 1 | public function pack(Data $data): string |
|
45 | } |
||
46 | } |
||
47 |