1 | <?php |
||
7 | abstract class AbstractManifestLoader implements ManifestLoaderInterface |
||
8 | { |
||
9 | private $path; |
||
10 | private $rootKey; |
||
11 | |||
12 | abstract protected function parse($path); |
||
13 | |||
14 | 3 | public function __construct($path, $rootKey = null) |
|
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | 3 | public function load() |
|
28 | { |
||
29 | 3 | $entries = $this->parse($this->path); |
|
30 | |||
31 | 3 | if (!empty($this->rootKey)) { |
|
32 | if (!isset($entries[$this->rootKey])) { |
||
33 | throw new \InvalidArgumentException('Manifest file contains no '.$this->rootKey.' key'); |
||
34 | } |
||
35 | |||
36 | $entries = $entries[$this->rootKey]; |
||
37 | } |
||
38 | |||
39 | 3 | return new Manifest($entries); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 3 | public function getPath() |
|
49 | } |
||
50 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.