YamlReader::readFromFile()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
/**
4
 * Phoole (PHP7.2+)
5
 *
6
 * @category  Library
7
 * @package   Phoole\Base
8
 * @copyright Copyright (c) 2019 Hong Zhang
9
 */
10
declare(strict_types=1);
11
12
namespace Phoole\Base\Reader;
13
14
/**
15
 * YamlReader
16
 *
17
 * @package Phoole\Base
18
 */
19
class YamlReader extends AbstractReader
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected function readFromFile($path)
25
    {
26
        try {
27
            $data = \yaml_parse_file($path);
28
            if ($data === FALSE) {
29
                throw new \RuntimeException("Parse $path error");
30
            }
31
        } catch (\Exception $e) {
32
            throw new \RuntimeException($e->getMessage());
33
        }
34
        return $data;
35
    }
36
}
37