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

Paginator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getPageSize() 0 4 1
A getCurrentPage() 0 4 1
A getNumberOfRecords() 0 4 1
A getLastPage() 0 4 1
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