| 1 | <?php | ||
| 10 | final class FileLoader implements LoaderInterface | ||
| 11 | { | ||
| 12 | /** | ||
| 13 | * @var JsonDecoderInterface | ||
| 14 | */ | ||
| 15 | private $jsonDecoder; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @param JsonDecoderInterface $jsonDecoder | ||
| 19 | */ | ||
| 20 | 62 | public function __construct(JsonDecoderInterface $jsonDecoder = null) | |
| 24 | |||
| 25 | /** | ||
| 26 |      * {@inheritdoc} | ||
| 27 | */ | ||
| 28 | 38 | public function load($path) | |
| 29 |     { | ||
| 30 | 38 | // Check if the file path is 'relative', i.e. starts with a dot. | |
| 31 | 4 |         if(substr($path,0,1) === '.') { | |
| 32 | // If the path is 'relative' check for an defined AR_JSON_SCHEMA_DIR | ||
| 33 |             $schemaDir = getenv('AR_JSON_SCHEMA_DIR'); | ||
| 34 | 34 | ||
| 35 | // If root dir isn't set use the default relative path of './schema' | ||
| 36 |             if(! $schemaDir) { | ||
| 37 | $schemaDir = getcwd() . '/schema'; | ||
| 51 |