FileLoader::getFilepathWithExtension()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Amock\Loader;
4
5
class FileLoader implements Loader
6
{
7
    private $filepath;
8
9 4
    public function __construct(string $filepath)
10
    {
11 4
        $this->filepath = $this->getFilepathWithExtension($filepath);
12 4
    }
13
14 4
    public function get(): string
15
    {
16 4
        return file_get_contents($this->filepath);
17
    }
18
19 4
    private function getFilepathWithExtension($filepath)
20
    {
21 4
        return strrpos($filepath, '.yml', -4) === false
22 2
            ? $filepath . '.yml'
23 4
            : $filepath;
24
    }
25
}
26