Conditions | 4 |
Paths | 6 |
Total Lines | 22 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
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'; |
||
38 | } |
||
39 | |||
40 | // Define the full path to pass to existing League Reference File Loader |
||
41 | $path = $schemaDir . ltrim($path, '.'); |
||
42 | } |
||
43 | |||
44 | if (!file_exists($path)) { |
||
45 | throw SchemaLoadingException::notFound($path); |
||
46 | } |
||
47 | |||
48 | return $this->jsonDecoder->decode(file_get_contents($path)); |
||
49 | } |
||
50 | } |
||
51 |