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

Ini::group()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 1
nc 1
nop 0
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