Completed
Pull Request — master (#5)
by Daniel
08:11 queued 06:07
created

Paginator::getLastPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Psi\Component\Grid;
4
5
class Paginator
6
{
7
    private $pageSize;
8
    private $currentPage;
9
    private $numberOfRecords;
10
11
    public function __construct(int $pageSize, int $currentPage, int $numberOfRecords = null)
12
    {
13
        $this->pageSize = $pageSize;
14
        $this->currentPage = $currentPage;
15
        $this->numberOfRecords = $numberOfRecords;
16
    }
17
18
    public function getPageSize(): int
19
    {
20
        return $this->pageSize;
21
    }
22
23
    public function getCurrentPage(): int
24
    {
25
        return $this->currentPage;
26
    }
27
28
    public function getNumberOfRecords(): int
29
    {
30
        return $this->numberOfRecords;
31
    }
32
33
    public function getLastPage(): int
34
    {
35
        return (int) ceil($this->numberOfRecords / $this->pageSize);
36
    }
37
}
38