| Conditions | 7 |
| Paths | 19 |
| Total Lines | 77 |
| Code Lines | 47 |
| 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 |
||
| 61 | protected function updateContent(ManialinkInterface $manialink) |
||
| 62 | { |
||
| 63 | parent::updateContent($manialink); |
||
| 64 | |||
| 65 | $manialink->getContentFrame()->removeAllChildren(); |
||
| 66 | |||
| 67 | $builder = new uiBuilder($this->uiFactory, $this->actionFactory, $manialink, $this); |
||
| 68 | |||
| 69 | $maps = $this->mapStorage->getMaps(); |
||
| 70 | |||
| 71 | $current = $this->mapStorage->getCurrentMap(); |
||
| 72 | |||
| 73 | $queue = $this->jukeboxService->getMapQueue(); |
||
| 74 | |||
| 75 | |||
| 76 | $x = 0; |
||
| 77 | |||
| 78 | $inc = '<uiLayoutLine margin="1">'; |
||
| 79 | foreach ($maps as $map) { |
||
| 80 | $juke = ""; |
||
| 81 | |||
| 82 | if ($x % 8 == 0) { |
||
| 83 | if ($x != 0) { |
||
| 84 | $inc .= '</uiLayoutRow>'; |
||
| 85 | } |
||
| 86 | $inc .= '<uiLayoutRow margin="1">'; |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($map->uId == $current->uId) { |
||
| 90 | $color = "0f03"; |
||
| 91 | $juke = "<uiLabel pos='1 -7' width='30' textColor='fff' textSize='1'>Map Currently Playing</uiLabel>"; |
||
| 92 | } else { |
||
| 93 | $color = "fff3"; |
||
| 94 | } |
||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | $n = $x + 1; |
||
|
|
|||
| 99 | |||
| 100 | |||
| 101 | $idx = 1; |
||
| 102 | $sym = ""; |
||
| 103 | $gtime = ""; |
||
| 104 | foreach ($queue as $qmap) { |
||
| 105 | if ($map->uId == $qmap->getMap()->uId) { |
||
| 106 | $nick = $qmap->getPlayer()->getNickName(); |
||
| 107 | $color = "ff03"; |
||
| 108 | $sym = "⏳".$idx; |
||
| 109 | $juke = "<uiLabel pos='1 -7' width='30' textColor='fff' textSize='1'>In Queue. Wished by $nick</uiLabel>"; |
||
| 110 | } |
||
| 111 | $idx += 1; |
||
| 112 | } |
||
| 113 | |||
| 114 | $inc .= <<<EOL |
||
| 115 | <frame size="40 10"> |
||
| 116 | <uiLabel actionCallback='callbackOk' actionParam='{$map->uId}' pos="32 -1" textColor="fff" textSize="4">$sym</uiLabel> |
||
| 117 | <uiLabel pos="1 -1" width="30" textColor="fff" textSize="1.5">{$map->name}</uiLabel> |
||
| 118 | <uiLabel pos="1 -4" width="30" textColor="fff" textSize="1">{$map->author} / {$gtime}</uiLabel> |
||
| 119 | $juke |
||
| 120 | <quad backgroundColor="$color" size="40 10"/> |
||
| 121 | </frame> |
||
| 122 | EOL; |
||
| 123 | $x++; |
||
| 124 | } |
||
| 125 | |||
| 126 | $inc .= '</uiLayoutRow>'; |
||
| 127 | $inc .= '</uiLayoutLine>'; |
||
| 128 | |||
| 129 | $manialink->getContentFrame()->addChild($builder->build(/** @lang text */ |
||
| 130 | <<<EOL |
||
| 131 | <window id="main"> |
||
| 132 | $inc |
||
| 133 | </window> |
||
| 134 | EOL |
||
| 135 | )); |
||
| 136 | |||
| 137 | } |
||
| 138 | |||
| 169 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.