IniFileParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsFileExtension() 0 4 1
A getFileContentsAsArray() 0 8 2
1
<?php
2
namespace UltraLite\ConfigReader\FileParser;
3
4
use UltraLite\ConfigReader\ConfigReaderException\ConfigFileUnparsable;
5
use UltraLite\ConfigReader\FileParser;
6
7
class IniFileParser implements FileParser
8
{
9
    public function supportsFileExtension(string $fileExtension): bool
10
    {
11
        return $fileExtension === 'ini';
12
    }
13
14
    /**
15
     * @throws ConfigFileUnparsable
16
     */
17
    public function getFileContentsAsArray(string $path): array
18
    {
19
        try {
20
            return parse_ini_file($path);
21
        } catch (\Throwable $throwable) {
22
            throw ConfigFileUnparsable::constructFromThrowable($throwable, $path);
23
        }
24
    }
25
}
26