ConfigurationFileLoader   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 18 3
A pathIsExistingAndReadableFile() 0 4 2
1
<?php
2
/**
3
 * @author stev leibelt <[email protected]>
4
 * @since 2015-05-31 
5
 */
6
7
namespace Net\Bazzline\Component\Locator\Process\Transformer\FileLoader;
8
9
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
10
use Net\Bazzline\Component\ProcessPipe\ExecutableInterface;
11
12
class ConfigurationFileLoader implements ExecutableInterface
13
{
14
    /**
15
     * @param string $input
16
     * @return array
17
     * @throws ExecutableException
18
     */
19
    public function execute($input = null)
20
    {
21
        if (!is_string($input)) {
22
            throw new ExecutableException(
23
                'input must be a string'
24
            );
25
        }
26
27
        if ($this->pathIsExistingAndReadableFile($input)) {
28
            $configuration = require_once $input;
29
        } else {
30
            throw new ExecutableException(
31
                'provided path must be a readable file'
32
            );
33
        }
34
35
        return $configuration;
36
    }
37
38
    /**
39
     * @param string $path
40
     * @return bool
41
     */
42
    private function pathIsExistingAndReadableFile($path)
43
    {
44
        return ((is_file($path)) && (is_readable($path)));
45
    }
46
}