Positions::getFirstPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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