CliExpandPager   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 21
ccs 12
cts 12
cp 1
rs 10
wmc 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B render() 0 19 10
1
<?php
2
3
namespace kalanis\kw_paging\Render;
4
5
6
/**
7
 * Class CliExpandPager
8
 * @package kalanis\kw_paging\Render
9
 * Pager for displaying on CLI
10
 */
11
class CliExpandPager extends CliPager
12
{
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
    }
33
}
34