Conditions | 13 |
Paths | 11 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
51 | public function buildActionButtons() |
||
52 | { |
||
53 | foreach ($this->actionTypes as $key => $type) { |
||
54 | if (is_string($key) && in_array($key, array_keys(self::ACTION_DEFINITIONS))) { |
||
55 | if ($type instanceof Closure) { |
||
56 | $class = self::ACTION_DEFINITIONS[$key]; |
||
57 | $this->fillActionObjects(new $class(['url' => $type])); |
||
58 | continue; |
||
59 | } |
||
60 | |||
61 | if (is_string($type) && in_array($type, array_keys(self::ACTION_DEFINITIONS))) { |
||
62 | $class = self::ACTION_DEFINITIONS[$type]; |
||
63 | $this->fillActionObjects(new $class); |
||
64 | continue; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | if (is_numeric($key)) { |
||
69 | if (is_string($type) && in_array($type, array_keys(self::ACTION_DEFINITIONS))) { |
||
70 | $class = self::ACTION_DEFINITIONS[$type]; |
||
71 | $this->fillActionObjects(new $class); |
||
72 | continue; |
||
73 | } |
||
74 | |||
75 | if (is_array($type) && isset($type['class']) && class_exists($type['class'])) { |
||
76 | $this->fillActionObjects(new $type['class']($type)); |
||
77 | } |
||
113 |