Completed
Push — master ( b06bec...8d39d6 )
by Xeriab
03:49
created

Neon   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 34
rs 10
c 1
b 0
f 0
ccs 13
cts 13
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 16 2
A getSupportedFileExtensions() 0 4 1
1
<?php
2
3
/**
4
 * Konfig
5
 *
6
 * Yet another simple configuration loader library.
7
 *
8
 * @author  Xeriab Nabil (aka KodeBurner) <[email protected]>
9
 * @license https://raw.github.com/xeriab/konfig/master/LICENSE MIT
10
 * @link    https://xeriab.github.io/projects/konfig
11
 */
12
13
namespace Exen\Konfig\FileParser;
14
15
use Exen\Konfig\Exception\ParseException;
16
17
use Nette\Neon\Neon as NeonParser;
18
19
class Neon extends AbstractFileParser
20
{
21
    /**
22
     * {@inheritDoc}
23
     * Loads a NEON file as an array
24
     *
25
     * @throws ParseException If there is an error parsing NEON file
26
     * @since 0.1.0
27
     */
28 6
    public function parse($path)
29
    {
30 6
        $data = null;
31
32
        try {
33 6
            $data = NeonParser::decode(file_get_contents(realpath($path)));
34 5
        } catch (\Exception $ex) {
35 3
            throw new ParseException([
36 3
                'message' => 'Error parsing NEON file',
37 3
                'file' => $path,
38 3
                'exception' => $ex,
39 2
            ]);
40 2
        }
41
42 3
        return $data;
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 3
    public function getSupportedFileExtensions()
49
    {
50 3
        return ['neon'];
51
    }
52
}
53
54
// END OF ./src/FileParser/Neon.php FILE
55