| Conditions | 2 |
| Paths | 2 |
| Total Lines | 77 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 22 | protected function createContent(ManialinkInterface $manialink) |
||
| 23 | { |
||
| 24 | parent::createContent($manialink); |
||
| 25 | |||
| 26 | $tooltip = new uiTooltip(); |
||
| 27 | $manialink->addChild($tooltip); |
||
| 28 | |||
| 29 | $label = new uiLabel("Test", uiLabel::TYPE_NORMAL); |
||
| 30 | $tooltip->addTooltip($label, "tooltip test"); |
||
| 31 | |||
| 32 | $manialink->addChild($label); |
||
| 33 | |||
| 34 | $checkbox = new uiCheckbox("test checkbox 1", "checkbox1"); |
||
| 35 | $tooltip->addTooltip($checkbox, "testing 123"); |
||
| 36 | |||
| 37 | $checkbox2 = new uiCheckbox("test checkbox 2", "checkbox2"); |
||
| 38 | $tooltip->addTooltip($checkbox2, "testing"); |
||
| 39 | $line1 = new layoutRow(0, 0, [$checkbox, $checkbox2], 0); |
||
| 40 | |||
| 41 | $ok = new uiButton("Apply", uiButton::TYPE_DECORATED); |
||
| 42 | $tooltip->addTooltip($ok, "ridicolously long description text is here!"); |
||
| 43 | $ok->setAction($this->actionFactory->createManialinkAction($manialink, [$this, 'ok'], ["ok" => "ok"])); |
||
| 44 | |||
| 45 | $cancel = new uiButton("Cancel"); |
||
| 46 | $cancel->setAction($this->actionFactory->createManialinkAction($manialink, [$this, 'ok'], ["ok" => "cancel"])); |
||
| 47 | |||
| 48 | $line2 = new layoutLine(0, 0, [$ok, $cancel], 1); |
||
| 49 | |||
| 50 | $line3 = new layoutRow(55, 0, [], 1); |
||
| 51 | |||
| 52 | for ($x = 0; $x < 10; $x++) { |
||
| 53 | $btn = new uiCheckbox('box'.$x, 'cb_'.$x); |
||
| 54 | $btn->setPosition(0, 0); |
||
| 55 | $tooltip->addTooltip($btn, "long description that should go over the bounding box".$x); |
||
| 56 | $line3->addChild($btn); |
||
| 57 | } |
||
| 58 | $btn = new uiCheckbox('box11', 'cb_11'); |
||
| 59 | $btn->setPosition(20, 0); |
||
| 60 | $line3->addChild($btn); |
||
| 61 | |||
| 62 | $btn = new uiCheckbox('box11', 'cb_11'); |
||
| 63 | $btn->setPosition(50, 0); |
||
| 64 | $line3->addChild($btn); |
||
| 65 | |||
| 66 | $scrollable = new layoutScrollable($line3, 55, 30); |
||
| 67 | $scrollable->setAxis(true, true); |
||
| 68 | $manialink->addChild($scrollable); |
||
| 69 | |||
| 70 | |||
| 71 | $row = new layoutRow(0, -10, [$line1, $line2], 0); |
||
| 72 | |||
| 73 | $scrollable = new layoutScrollable($row, 40, 30); |
||
| 74 | $scrollable->setAxis(true, true); |
||
| 75 | $manialink->addChild($scrollable); |
||
| 76 | |||
| 77 | |||
| 78 | $dropdown = new uiDropdown("dropdown", ["option1" => 1, "option2" => 2]); |
||
| 79 | $dropdown->setPosition(97, 0); |
||
| 80 | $tooltip->addTooltip($dropdown, "test"); |
||
| 81 | $manialink->addChild($dropdown); |
||
| 82 | |||
| 83 | $dropdown = new uiDropdown("style", ["tech" => "tech", "fullspeed" => "fullspeed", "speedtech" => "speedtech"]); |
||
| 84 | $dropdown->setPosition(130, 0); |
||
| 85 | $manialink->addChild($dropdown); |
||
| 86 | |||
| 87 | |||
| 88 | $input = new uiInput("input1", "test text", 30, "Password"); |
||
| 89 | $input->setPosition(130, -20); |
||
| 90 | $tooltip->addTooltip($input, "test"); |
||
| 91 | $manialink->addChild($input); |
||
| 92 | |||
| 93 | $input = new uiTextbox("input2", "test\ntest2\ntest3\nest4\ntest5", 5, 30); |
||
| 94 | $input->setPosition(130, -30); |
||
| 95 | $tooltip->addTooltip($input, "test2"); |
||
| 96 | $manialink->addChild($input); |
||
| 97 | |||
| 98 | } |
||
| 99 | |||
| 107 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.