| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 35 |
| 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 |
||
| 83 | public function build( |
||
| 84 | ManiaLink $manialink, |
||
| 85 | Frame $mainFrame, |
||
| 86 | $name, |
||
| 87 | $sizeX, |
||
| 88 | $sizeY |
||
| 89 | ) { |
||
| 90 | // Creating sub frame to keep all the pieces together. Position needs to be top left corner. |
||
| 91 | $frame = new Frame(); |
||
| 92 | $frame->setPosition(-160 - $mainFrame->getX(), 90 - $mainFrame->getY()); |
||
| 93 | |||
| 94 | $tabsFrame = new Frame(); |
||
| 95 | $tabsFrame->setPosition(-144 - $mainFrame->getX(), 82- $mainFrame->getY()); |
||
| 96 | |||
| 97 | // Creating the tabs. |
||
| 98 | $mainFrame->addChild( |
||
| 99 | $this->menuTabsFactory->createTabsMenu( |
||
|
|
|||
| 100 | $this->manialinkInterface, |
||
| 101 | $tabsFrame, |
||
| 102 | $this->menuItemProvider->getRootItem(), |
||
| 103 | [$this, 'callbackItemClick'], |
||
| 104 | 'admin/admin' |
||
| 105 | ) |
||
| 106 | ); |
||
| 107 | $mainFrame->addChild($tabsFrame); |
||
| 108 | $mainFrame->addChild($frame); |
||
| 109 | |||
| 110 | $closeButton = $this->uiFactory->createButton('Close', uiButton::TYPE_DECORATED); |
||
| 111 | $closeButton->setBorderColor(uiButton::COLOR_WARNING)->setFocusColor(uiButton::COLOR_WARNING); |
||
| 112 | $closeButton->setPosition(300, -20); |
||
| 113 | $frame->addChild($closeButton); |
||
| 114 | |||
| 115 | |||
| 116 | /* |
||
| 117 | * Adding background frame |
||
| 118 | */ |
||
| 119 | $bgFrame = Frame::create("background"); |
||
| 120 | $quad = new Quad(); |
||
| 121 | $quad->addClass("bg") |
||
| 122 | ->setId("mainBg") |
||
| 123 | ->setPosition(0, 0) |
||
| 124 | ->setSize(322, 182); |
||
| 125 | $quad->setAlign("left", "top") |
||
| 126 | ->setStyles("Bgs1", "BgDialogBlur"); |
||
| 127 | $bgFrame->addChild($quad); |
||
| 128 | |||
| 129 | $frame->addChild($bgFrame); |
||
| 130 | |||
| 131 | |||
| 132 | $manialink->addChild($this->maniaScriptFactory->createScript([''])); |
||
| 133 | |||
| 134 | return $closeButton; |
||
| 135 | } |
||
| 136 | |||
| 163 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: