| Total Complexity | 12 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class Spyc implements ParserInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @return bool |
||
| 15 | */ |
||
| 16 | 1 | public static function isAvailable() |
|
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param string $path |
||
| 23 | * @return null|array |
||
| 24 | */ |
||
| 25 | 3 | public function parseFile($path) |
|
| 26 | { |
||
| 27 | 3 | $fsIsStreamUri = Lib::fsIsStreamUri($path); |
|
| 28 | 3 | if (!$fsIsStreamUri && (!is_file($path) || !is_readable($path))) { |
|
| 29 | 1 | return null; |
|
| 30 | } |
||
| 31 | |||
| 32 | 3 | $error = ErrorCatcher::create(); |
|
| 33 | |||
| 34 | 3 | if ($fsIsStreamUri) { |
|
| 35 | 1 | $path = file_get_contents($path); |
|
| 36 | } |
||
| 37 | |||
| 38 | 3 | $array = MustangostangSpyc::YAMLLoad($path); |
|
| 39 | |||
| 40 | 3 | if ($error->end() || !is_array($array) || array() === $array) { |
|
| 41 | 1 | return null; |
|
| 42 | } |
||
| 43 | |||
| 44 | 3 | $keys = array_keys($array); |
|
| 45 | 3 | if ($keys === range(0, count($array) - 1, 1)) { |
|
| 46 | 2 | return null; |
|
| 47 | } |
||
| 48 | |||
| 49 | 1 | return $array; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param string $buffer |
||
| 54 | * @return null|array |
||
| 55 | */ |
||
| 56 | 1 | public function parseBuffer($buffer) |
|
| 63 | } |
||
| 64 | } |
||
| 65 |