PhpArrayFileParser::supportsFileExtension()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace UltraLite\ConfigReader\FileParser;
3
4
use UltraLite\ConfigReader\ConfigReaderException\ConfigFileUnparsable;
5
use UltraLite\ConfigReader\FileParser;
6
7
class PhpArrayFileParser implements FileParser
8
{
9
    public function supportsFileExtension(string $fileExtension): bool
10
    {
11
        return $fileExtension === 'php';
12
    }
13
14
    /**
15
     * @throws ConfigFileUnparsable
16
     */
17
    public function getFileContentsAsArray(string $path): array
18
    {
19
        $contents = require $path;
20
        if (!is_array($contents)) {
21
            throw ConfigFileUnparsable::constructFromPath($path);
22
        }
23
        return $contents;
24
    }
25
}
26