PHP::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
namespace Fyuze\Config\Parsers;
3
4
use SplFileInfo;
5
use RuntimeException;
6
7
class PHP
8
{
9
    /**
10
     * @var array
11
     */
12
    public static $extensions = ['php'];
13
14
    /**
15
     * @param SplFileInfo $file
16
     * @return array
17
     * @throws RuntimeException
18
     */
19 14
    public function parse(SplFileInfo $file)
20
    {
21 14
        $contents = require $file->getRealPath();
22
23 14
        if (!is_array($contents)) {
24 1
            throw new RuntimeException(sprintf('The configuration file %s did not return an array', $file->getBasename('.php')));
25
        }
26
27 13
        return $contents;
28
    }
29
}
30