Conditions | 10 |
Paths | 50 |
Total Lines | 36 |
Code Lines | 22 |
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 |
||
19 | public function configure(ConfigurableObjectInterface $config) |
||
20 | { |
||
21 | if ($this->config === null) { |
||
22 | $file = 'magium.json'; |
||
23 | $dir = $this->baseDir; |
||
24 | if ($dir === null) { |
||
25 | $dir = __DIR__; |
||
26 | } |
||
27 | $count = 0; |
||
28 | while ($count++ < 10) { |
||
29 | $filePath = $dir . '/' . $file; |
||
30 | if (file_exists($filePath)) { |
||
31 | $this->config = json_decode(file_get_contents($filePath), true); |
||
32 | break; |
||
33 | } |
||
34 | $dir = realpath($dir . '/..'); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | if ($this->config === null) { |
||
39 | $this->config = false; |
||
40 | } |
||
41 | |||
42 | if ($this->config) { |
||
43 | $classes = $this->introspectClass($config); |
||
44 | foreach ($classes as $class) { |
||
45 | $className = strtolower($class); |
||
46 | if (isset($this->config['magium'][$className])) { |
||
47 | foreach ($this->config['magium'][$className] as $property => $value) { |
||
48 | $config->set($property, $value); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | |||
54 | } |
||
55 | |||
57 |