Completed
Push — master ( 0c83ff...fee93b )
by Xeriab
04:37
created

Ini   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 12 2
A load() 0 4 1
A group() 0 4 1
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 load($overwrite = false, $cache = true)
0 ignored issues
show
Unused Code introduced by
The parameter $overwrite is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $cache is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44
        // Nothing to put here
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     * @since 0.1
50
     */
51
    public function group()
52
    {
53
        // Nothing to put here
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     * @since 0.1
59
     */
60
    public function getSupportedFileExtensions()
61
    {
62
        return ['ini', 'cfg', 'conf'];
63
    }
64
}
65
66
#: END OF ./src/FileParser/Ini.php FILE
67