| Conditions | 7 |
| Paths | 19 |
| Total Lines | 72 |
| Code Lines | 44 |
| 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 | $inc = '<uiLayoutLine margin="1">'; |
||
| 78 | foreach ($maps as $map) { |
||
| 79 | if ($x % 6 == 0) { |
||
| 80 | if ($x != 0) { |
||
| 81 | $inc .= '</uiLayoutRow>'; |
||
| 82 | } |
||
| 83 | $inc .= '<uiLayoutRow margin="1">'; |
||
| 84 | } |
||
| 85 | |||
| 86 | if ($map->uId == $current->uId) { |
||
| 87 | $color = "3af3"; |
||
| 88 | } else { |
||
| 89 | $color = "fff3"; |
||
| 90 | } |
||
| 91 | |||
| 92 | |||
| 93 | $gtime = $this->time->timeToText($map->goldTime); |
||
| 94 | $n = $x + 1; |
||
| 95 | |||
| 96 | $juke = ""; |
||
| 97 | $idx = 1; |
||
| 98 | foreach ($queue as $qmap) { |
||
| 99 | if ($map->uId == $qmap->getMap()->uId) { |
||
| 100 | $nick = $qmap->getPlayer()->getNickName(); |
||
| 101 | $color = "0f03"; |
||
| 102 | $juke = "<uiLabel pos='1 -10' width='30' textColor='fff' textSize='1'>{$idx} queue by $nick </uiLabel>"; |
||
| 103 | } |
||
| 104 | $idx += 1; |
||
| 105 | } |
||
| 106 | |||
| 107 | $inc .= <<<EOL |
||
| 108 | <frame size="40 14"> |
||
| 109 | <quad actionCallback="callbackOk" actionParam="{$map->uId}" backgroundColor="$color" size="40 14"/> |
||
| 110 | |||
| 111 | <uiLabel pos="1 -1" width="30" textColor="fff" textSize="1.5">$n. {$map->name}</uiLabel> |
||
| 112 | <uiLabel pos="1 -4" width="30" textColor="fff" textSize="1">{$map->author}</uiLabel> |
||
| 113 | <uiLabel pos="1 -7" width="30" textColor="fff" textSize="1">{$map->environnement} / {$gtime} </uiLabel> |
||
| 114 | $juke |
||
| 115 | |||
| 116 | </frame> |
||
| 117 | EOL; |
||
| 118 | $x++; |
||
| 119 | } |
||
| 120 | |||
| 121 | $inc .= '</uiLayoutRow>'; |
||
| 122 | $inc .= '</uiLayoutLine>'; |
||
| 123 | |||
| 124 | $manialink->getContentFrame()->addChild($builder->build(/** @lang text */ |
||
| 125 | <<<EOL |
||
| 126 | <window id="main"> |
||
| 127 | $inc |
||
| 128 | </window> |
||
| 129 | EOL |
||
| 130 | )); |
||
| 131 | |||
| 132 | } |
||
| 133 | |||
| 164 |