FileLoader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
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