Completed
Pull Request — master (#5)
by Daniel
08:08 queued 06:02
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
declare(strict_types=1);
4
5
namespace Psi\Component\Grid;
6
7
class Paginator
8
{
9
    private $pageSize;
10
    private $currentPage;
11
    private $numberOfRecords;
12
13
    public function __construct(int $pageSize, int $currentPage, int $numberOfRecords = null)
14
    {
15
        $this->pageSize = $pageSize;
16
        $this->currentPage = $currentPage;
17
        $this->numberOfRecords = $numberOfRecords;
18
    }
19
20
    public function getPageSize(): int
21
    {
22
        return $this->pageSize;
23
    }
24
25
    public function getCurrentPage(): int
26
    {
27
        return $this->currentPage;
28
    }
29
30
    public function getNumberOfRecords(): int
31
    {
32
        return $this->numberOfRecords;
33
    }
34
35
    public function getLastPage(): int
36
    {
37
        return (int) ceil($this->numberOfRecords / $this->pageSize);
38
    }
39
}
40