Positions   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 44
ccs 17
cts 17
cp 1
rs 10
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getFirstPage() 0 3 1
A getPager() 0 3 1
A __construct() 0 3 1
A prevPageExists() 0 3 1
A getLastPage() 0 3 1
A getNextPage() 0 3 1
A nextPageExists() 0 3 1
A getPrevPage() 0 3 1
1
<?php
2
3
namespace kalanis\kw_paging;
4
5
6
use kalanis\kw_pager\Interfaces\IPager;
7
8
9
class Positions implements Interfaces\IPositions
10
{
11
    public const FIRST_PAGE = 1;
12
13
    protected IPager $pager;
14
15 22
    public function __construct(IPager $pager)
16
    {
17 22
        $this->pager = $pager;
18 22
    }
19
20 17
    public function nextPageExists(): bool
21
    {
22 17
        return $this->pager->pageExists($this->getNextPage());
23
    }
24
25 17
    public function getNextPage(): int
26
    {
27 17
        return $this->pager->getActualPage() + 1;
28
    }
29
30 17
    public function prevPageExists(): bool
31
    {
32 17
        return $this->pager->pageExists($this->getPrevPage());
33
    }
34
35 17
    public function getPrevPage(): int
36
    {
37 17
        return $this->pager->getActualPage() - 1;
38
    }
39
40 17
    public function getFirstPage(): int
41
    {
42 17
        return static::FIRST_PAGE;
43
    }
44
45 13
    public function getLastPage(): int
46
    {
47 13
        return $this->pager->getPagesCount();
48
    }
49
50 21
    public function getPager(): IPager
51
    {
52 21
        return $this->pager;
53
    }
54
}
55