Ini   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 14 3
A getSupportedExtensions() 0 4 1
1
<?php
2
3
namespace Nip\Config\FileParser;
4
5
use Nip\Config\Exception\ParseException;
6
7
/**
8
 * Class Ini
9
 * @package Nip\Config\FileParser
10
 */
11
class Ini extends AbstractFileParser
12
{
13
    /**
14
     * {@inheritDoc}
15
     * Parses an INI file as an array
16
     *
17
     * @throws ParseException If there is an error parsing the INI file
18
     */
19 1
    public function parse()
20
    {
21 1
        if (defined('INI_SCANNER_TYPED')) {
22 1
            $data = parse_ini_file($this->getPath(), true, INI_SCANNER_TYPED);
23
        } else {
24
            $data = parse_ini_file($this->getPath(), true);
25
        }
26 1
        if ($data === false) {
27
            $error = error_get_last();
28
            throw new ParseException($error);
29
        }
30
31 1
        return $data;
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function getSupportedExtensions()
38
    {
39
        return ['ini'];
40
    }
41
}
42