FileFetcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setPath() 0 4 1
A fetchContentAsStringOrThrowRuntimeException() 0 16 2
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2017-02-01
5
 */
6
namespace Net\Bazzline\Component\ApacheServerStatusParser\Service\Content\Fetcher;
7
8
use RuntimeException;
9
10
class FileFetcher extends AbstractFetcher
11
{
12
    /** @var string */
13
    private $path;
14
15
    /**
16
     * @param string $path
17
     */
18
    public function setPath($path)
19
    {
20
        $this->path = $path;
21
    }
22
23
    /**
24
     * @return string
25
     * @throws RuntimeException
26
     */
27
    protected function fetchContentAsStringOrThrowRuntimeException()
28
    {
29
        //begin of dependencies
30
        $path = $this->path;
31
        //end of dependencies
32
33
        //begin of business logic
34
        if (!is_readable($path)) {
35
            throw new RuntimeException(
36
                'provided path "' . $path . '" is not readable.'
37
            );
38
        }
39
40
        return file_get_contents($path);
41
        //begin of business logic
42
    }
43
}
44