FileLoader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 19
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilepathWithExtension() 0 5 2
A __construct() 0 3 1
A get() 0 3 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