| Total Complexity | 8 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 50% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | abstract class AbstractReader implements ReaderInterface |
||
| 14 | { |
||
| 15 | protected Builder $builder; |
||
| 16 | |||
| 17 | 4 | public function __construct(Builder $builder) |
|
| 20 | 4 | } |
|
| 21 | |||
| 22 | 2 | public function read($path): array |
|
| 23 | { |
||
| 24 | 2 | $skippable = 0 === strncmp($path, '?', 1); |
|
| 25 | 2 | if ($skippable) { |
|
| 26 | $path = substr($path, 1); |
||
| 27 | } |
||
| 28 | |||
| 29 | 2 | if (is_readable($path)) { |
|
| 30 | 2 | $res = $this->readRaw($path); |
|
| 31 | |||
| 32 | 2 | return is_array($res) ? $res : []; |
|
| 33 | } |
||
| 34 | |||
| 35 | if (!$skippable) { |
||
| 36 | throw new FailedReadException("Failed read file: $path"); |
||
| 37 | } |
||
| 38 | |||
| 39 | return []; |
||
| 40 | } |
||
| 41 | |||
| 42 | protected function getFileContents(string $path): string |
||
| 50 | } |
||
| 51 | |||
| 52 | abstract protected function readRaw(string $path); |
||
| 53 | } |
||
| 54 |