Conditions | 10 |
Paths | 10 |
Total Lines | 48 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
34 | public function get($configuration) |
||
35 | { |
||
36 | |||
37 | if(!is_string($configuration)) |
||
38 | throw new LamentException($configuration); |
||
39 | |||
40 | if($this->has($configuration)) |
||
41 | return $this->configurations[$configuration]; |
||
42 | |||
43 | |||
44 | // fallbacks |
||
45 | if(preg_match('/^settings\./', $configuration, $m) === 1) |
||
46 | { |
||
47 | $ret = $this->configurations; |
||
48 | foreach(explode('.', $configuration) as $k) |
||
49 | { |
||
50 | if(!isset($ret[$k])) |
||
51 | throw new ConfigurationException($configuration); |
||
52 | $ret = $ret[$k]; |
||
53 | } |
||
54 | |||
55 | return $ret; |
||
56 | } |
||
57 | elseif(class_exists($configuration)) // auto create instances |
||
58 | { |
||
59 | |||
60 | $rc = new \ReflectionClass($configuration); |
||
61 | |||
62 | $construction_args = []; |
||
63 | $instance = null; |
||
64 | if(!is_null($rc->getConstructor())) |
||
65 | { |
||
66 | foreach($rc->getConstructor()->getParameters() as $param) |
||
67 | { |
||
68 | $construction_args []= $this->get($param->getType().''); |
||
69 | } |
||
70 | $instance = $rc->newInstanceArgs($construction_args); |
||
71 | } |
||
72 | else |
||
73 | $instance = $rc->newInstanceArgs(); |
||
74 | |||
75 | if($rc->hasMethod('set_container')) |
||
76 | $instance->set_container($this); |
||
77 | |||
78 | return $instance; |
||
79 | } |
||
80 | |||
81 | throw new ConfigurationException($configuration); |
||
82 | } |
||
87 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths