| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | class TxtDecoder implements DecoderInterface |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * Format supported by decoder |
||
| 27 | * |
||
| 28 | * @const string |
||
| 29 | */ |
||
| 30 | private const FORMAT = 'txt'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Line delimiter |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | private $lineDelimiter; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * TxtDecoder constructor. |
||
| 41 | * |
||
| 42 | * @param string $lineDelimiter Line delimiter |
||
| 43 | */ |
||
| 44 | public function __construct(string $lineDelimiter = "\n") |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | public function decode($data, $format, array $context = []) |
||
| 53 | { |
||
| 54 | if (empty($data)) { |
||
| 55 | return []; |
||
| 56 | } |
||
| 57 | |||
| 58 | $array = explode($this->lineDelimiter, $data); |
||
| 59 | |||
| 60 | return $array; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * {@inheritdoc} |
||
| 65 | */ |
||
| 66 | public function supportsDecoding($format) |
||
| 69 | } |
||
| 70 | } |
||
| 71 |