AbstractLoader   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
dl 0
loc 120
ccs 26
cts 28
cp 0.9286
rs 10
c 0
b 0
f 0
wmc 12
lcom 2
cbo 1

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPath() 0 4 1
A setPath() 0 4 1
A getResolvedPath() 0 8 2
A setResolvedPath() 0 4 1
resolvePath() 0 1 ?
A getResult() 0 6 2
getData() 0 1 ?
A returnConfigObject() 0 4 1
A setUseIncludePath() 0 4 1
A useIncludePath() 0 4 1
A setReturnConfigObject() 0 4 1
1
<?php
2
3
namespace Nip\Config\Loaders;
4
5
use Nip\Config\Config;
6
7
/**
8
 * Class AbstractLoader
9
 * @package Nip\Config\Loaders
10
 */
11
abstract class AbstractLoader
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $path;
17
18
    /**
19
     * @var string
20
     */
21
    protected $resolvedPath = null;
22
23
    /**
24
     * @var bool
25
     */
26
    protected $useIncludePath = false;
27
28
    /**
29
     * @var bool
30
     */
31
    protected $returnConfigObject = false;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param string $path A path where to look for resources
37
     */
38 1
    public function __construct($path)
39
    {
40 1
        $this->setPath($path);
41 1
    }
42
43
    /**
44
     * @return string
45
     */
46 1
    public function getPath()
47
    {
48 1
        return $this->path;
49
    }
50
51
    /**
52
     * @param string $path
53
     */
54 1
    public function setPath($path)
55
    {
56 1
        $this->path = $path;
57 1
    }
58
59
    /**
60
     * @return string
61
     */
62 1
    public function getResolvedPath()
63
    {
64 1
        if ($this->resolvedPath === null) {
65 1
            $this->setResolvedPath($this->resolvePath());
66
        }
67
68 1
        return $this->resolvedPath;
69
    }
70
71
    /**
72
     * @param string $resolvedPath
73
     */
74 1
    public function setResolvedPath($resolvedPath)
75
    {
76 1
        $this->resolvedPath = $resolvedPath;
77 1
    }
78
79
    /**
80
     * @return string
81
     */
82
    abstract protected function resolvePath();
83
84
    /**
85
     * @return string
86
     */
87 1
    public function getResult()
88
    {
89 1
        $data = $this->getData();
90
91 1
        return ($this->returnConfigObject()) ? new Config($data) : $data;
0 ignored issues
show
Documentation introduced by
$data is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    abstract protected function getData();
98
99
    /**
100
     * @return boolean
101
     */
102 1
    public function returnConfigObject()
103
    {
104 1
        return $this->returnConfigObject;
105
    }
106
107
    /**
108
     * @param boolean $useIncludePath
109
     */
110 1
    public function setUseIncludePath($useIncludePath)
111
    {
112 1
        $this->useIncludePath = $useIncludePath;
113 1
    }
114
115
    /**
116
     * @return boolean
117
     */
118
    public function useIncludePath()
119
    {
120
        return $this->useIncludePath;
121
    }
122
123
    /**
124
     * @param boolean $returnConfigObject
125
     */
126 1
    public function setReturnConfigObject($returnConfigObject)
127
    {
128 1
        $this->returnConfigObject = $returnConfigObject;
129 1
    }
130
}
131