| Total Complexity | 7 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| 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 | public function unpack(string $content): Data |
||
| 20 | { |
||
| 21 | $lines = explode(static::LINE_SEPARATOR, $content); |
||
| 22 | $libData = new Data(); |
||
| 23 | if (false !== $lines) { |
||
| 24 | foreach ($lines as $line) { |
||
| 25 | if (0 < mb_strlen($line)) { |
||
| 26 | $data = explode(static::DATA_SEPARATOR, $line); |
||
| 27 | if (false !== $data) { |
||
| 28 | list($key, $value, $nothing) = $data; |
||
| 29 | $libData->{$key} = $value; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 | return $libData->clear(); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function pack(Data $data): string |
||
| 45 | } |
||
| 46 | } |
||
| 47 |