YamlReader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A readFromFile() 0 12 3
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