Ini::getSupportedExtensions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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