Conditions | 11 |
Paths | 57 |
Total Lines | 38 |
Code Lines | 27 |
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 |
||
43 | protected function updateStyle($actions) |
||
44 | { |
||
45 | /** @var FormAction $action */ |
||
46 | foreach ($actions as $action) { |
||
47 | if ($action->hasMethod("getChildren")) { |
||
48 | foreach ($action->getChildren() as $child) { |
||
49 | $this->updateStyle($child); |
||
50 | } |
||
51 | continue; |
||
52 | } |
||
53 | if ($action->hasExtraClass('btn-outline-danger')) { |
||
54 | $action->removeExtraClass('btn-outline-danger'); |
||
55 | $action->addExtraClass('btn-danger'); |
||
56 | if ($action->hasExtraClass('font-icon-trash-bin')) { |
||
57 | $action->removeExtraClass('font-icon-trash-bin'); |
||
58 | $action->setIcon(MaterialIcons::DELETE); |
||
59 | } |
||
60 | } |
||
61 | if ($action->hasExtraClass('btn-outline-primary')) { |
||
62 | $action->removeExtraClass('btn-outline-primary'); |
||
63 | $action->addExtraClass('btn-outline-success'); |
||
64 | if ($action->hasExtraClass('font-icon-level-up')) { |
||
65 | $action->removeExtraClass('font-icon-level-up'); |
||
66 | $action->setIcon(MaterialIcons::KEYBOARD_RETURN); |
||
67 | } |
||
68 | if ($action->hasExtraClass('font-icon-angle-double-left')) { |
||
69 | $action->removeExtraClass('font-icon-angle-double-left'); |
||
70 | $action->setIcon(MaterialIcons::NAVIGATE_BEFORE); |
||
71 | } |
||
72 | if ($action->hasExtraClass('font-icon-angle-double-right')) { |
||
73 | $action->removeExtraClass('font-icon-angle-double-right'); |
||
74 | $action->addExtraClass('btn-flex btn-icon-end'); |
||
75 | $action->setIcon(MaterialIcons::NAVIGATE_NEXT); |
||
76 | } |
||
77 | } |
||
78 | if ($action->hasExtraClass('btn-primary')) { |
||
79 | $action->removeExtraClass('btn-primary'); |
||
80 | $action->addExtraClass('btn-success'); |
||
81 | } |
||
85 |