Completed
Push — master ( a3236c...9119a7 )
by Xeriab
13:18 queued 50s
created

Ini   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 12 2
A getSupportedFileExtensions() 0 4 1
1
<?php
2
/**
3
 * Konfig
4
 *
5
 * Yet another simple configuration file loader library.
6
 *
7
 * @author  Xeriab Nabil (aka KodeBurner) <[email protected]>
8
 * @license https://raw.github.com/xeriab/konfig/master/LICENSE MIT
9
 * @link    https://xeriab.github.io/projects/konfig
10
 */
11
namespace Exen\Konfig\FileParser;
12
13
use Exen\Konfig\Exception\ParseException;
14
use Piwik\Ini\INIReader as IniReader;
15
16
class Ini extends AbstractFileParser
17
{
18
    /**
19
     * {@inheritDoc}
20
     * Parses an INI file as an array
21
     *
22
     * @throws ParseException If there is an error parsing INI file
23
     * @since 0.1
24
     */
25
    public function parse($path)
26
    {
27
        $iniReader = new IniReader();
28
        $data      = $iniReader->readFile($path);
29
30
        if (empty($data)) {
31
            $error = error_get_last();
32
            throw new ParseException($error);
33
        }
34
35
        return $data;
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     * @since 0.1
41
     */
42
    public function getSupportedFileExtensions()
43
    {
44
        return ['ini', 'cfg', 'conf'];
45
    }
46
}
47
48
#: END OF ./src/FileParser/Ini.php FILE
49