Total Complexity | 10 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 25% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | abstract class AbstractReader |
||
22 | { |
||
23 | /** |
||
24 | * @var Builder |
||
25 | */ |
||
26 | protected $builder; |
||
27 | |||
28 | 1 | public function __construct(Builder $builder) |
|
29 | { |
||
30 | 1 | $this->builder = $builder; |
|
31 | 1 | } |
|
32 | |||
33 | 1 | public function getBuilder(): Builder |
|
36 | } |
||
37 | |||
38 | public function read($path) |
||
39 | { |
||
40 | $skippable = 0 === strncmp($path, '?', 1) ? '?' : ''; |
||
41 | if ($skippable) { |
||
42 | $path = substr($path, 1); |
||
43 | } |
||
44 | |||
45 | if (is_readable($path)) { |
||
46 | $res = $this->readRaw($path); |
||
47 | |||
48 | return is_array($res) ? $res : []; |
||
49 | } |
||
50 | |||
51 | if (empty($skippable)) { |
||
52 | throw new FailedReadException("failed read file: $path"); |
||
53 | } |
||
54 | |||
55 | return []; |
||
56 | } |
||
57 | |||
58 | public function getFileContents($path) |
||
66 | } |
||
67 | |||
68 | abstract public function readRaw($path); |
||
69 | } |
||
70 |