| 1 | <?php |
||
| 11 | /** |
||
| 12 | * YAML File Loader |
||
| 13 | */ |
||
| 14 | final class YamlFileLoader implements LoaderInterface |
||
| 15 | { |
||
| 16 | private string $filePath; |
||
|
|
|||
| 17 | private array $data; |
||
| 18 | |||
| 19 | public function __construct(string $filePath) |
||
| 20 | { |
||
| 21 | Assert::fileExists($filePath); |
||
| 22 | $this->filePath = $filePath; |
||
| 23 | |||
| 24 | $fileContent = file_get_contents($filePath); |
||
| 25 | Assert::string($fileContent); |
||
| 26 | |||
| 27 | $this->data = Yaml::parse($fileContent, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE + Yaml::PARSE_OBJECT); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getData(): array |
||
| 31 | { |
||
| 32 | return $this->data; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getSourceFilePath(): string |
||
| 36 | { |
||
| 37 | return $this->filePath; |
||
| 38 | } |
||
| 39 | } |
||
| 40 |