Conditions | 10 |
Paths | 97 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 10 |
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 |
||
13 | 4 | public function render(bool $showPositions = true): string |
|
14 | { |
||
15 | 4 | if (!$this->getPositions()->prevPageExists() && !$this->getPositions()->nextPageExists()) { |
|
16 | 1 | return $this->getFilledText($this->getPositions()); |
|
17 | } |
||
18 | 3 | $pages = []; |
|
19 | |||
20 | 3 | $pages[] = $this->getPositions()->prevPageExists() ? static::PREV_PAGE . static::PREV_PAGE . ' ' . $this->getPositions()->getFirstPage() : static::NONE_PAGE . static::NONE_PAGE ; |
|
21 | 3 | $pages[] = $this->getPositions()->prevPageExists() ? static::PREV_PAGE . ' ' . $this->getPositions()->getPrevPage() : static::NONE_PAGE ; |
|
22 | |||
23 | 3 | foreach ($this->getDisplayPages() as $displayPage) { |
|
24 | 3 | $current = ($this->getPositions()->getPager()->getActualPage() == $displayPage); |
|
25 | 3 | $pages[] = $current ? static::SELECT_PAGE . $displayPage . static::SELECT_PAGE : $displayPage ; |
|
26 | } |
||
27 | |||
28 | 3 | $pages[] = $this->getPositions()->nextPageExists() ? $this->getPositions()->getNextPage() . ' ' . static::NEXT_PAGE : static::NONE_PAGE ; |
|
29 | 3 | $pages[] = $this->getPositions()->nextPageExists() ? $this->getPositions()->getLastPage() . ' ' . static::NEXT_PAGE . static::NEXT_PAGE : static::NONE_PAGE . static::NONE_PAGE ; |
|
30 | |||
31 | 3 | return implode(' | ', $pages) . ( $showPositions ? (PHP_EOL . $this->getFilledText($this->getPositions()) ) : ''); |
|
32 | } |
||
34 |