Passed
Pull Request — master (#40)
by Chema
03:06
created

PhpConfigReader::canRead()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Config\ConfigReader;
6
7
use Gacela\Framework\Config\ConfigReaderInterface;
8
9
final class PhpConfigReader implements ConfigReaderInterface
10
{
11 3
    public function canRead(string $absolutePath): bool
12
    {
13 3
        $extension = pathinfo($absolutePath, PATHINFO_EXTENSION);
14
15 3
        return 'php' === $extension;
16
    }
17
18 3
    public function read(string $absolutePath): array
19
    {
20 3
        if (!file_exists($absolutePath)) {
21 1
            return [];
22
        }
23
24
        /** @var null|array $content */
25 3
        $content = include $absolutePath;
26
27 3
        return is_array($content) ? $content : [];
28
    }
29
}
30