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