Completed
Pull Request — develop (#79)
by
unknown
44:24 queued 32:59
created

Neon   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 15 2
A getSupportedExtensions() 0 4 1
1
<?php
2
3
namespace Noodlehaus\FileParser;
4
5
use Exception;
6
use Nette\Neon\Neon as NetteNeon;
7
use Noodlehaus\Exception\ParseException;
8
9
/**
10
 * NEON file parser
11
 *
12
 * @package    Config
13
 * @author     oNeDaL <[email protected]>
14
 * @link       https://github.com/onedal88/config
15
 * @license    MIT
16
 */
17
class Neon implements FileParserInterface
18
{
19
    /**
20
     * {@inheritDoc}
21
     * Loads a NEON file as an array
22
     *
23
     * @throws ParseException If If there is an error parsing the NEON file
24
     */
25
    public function parse($path)
26
    {
27
        try {
28
            $data = NetteNeon::decode(file_get_contents($path));
29
        } catch (Exception $exception) {
30
            throw new ParseException(
31
                array(
32
                    'message'   => 'Error parsing NEON file',
33
                    'exception' => $exception,
34
                )
35
            );
36
        }
37
38
        return $data;
39
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    public function getSupportedExtensions()
45
    {
46
        return array('neon');
47
    }
48
}
49