Page   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPageNumber() 0 3 1
A count() 0 3 1
A __construct() 0 4 1
A __toString() 0 3 1
1
<?php
2
3
namespace BenTools\Pager\Model;
4
5
use BenTools\Pager\Contract\PageInterface;
6
7
final class Page implements PageInterface
8
{
9
    /**
10
     * @var int
11
     */
12
    private $pageNumber;
13
14
    /**
15
     * @var int
16
     */
17
    private $nbItems;
18
19
    /**
20
     * Page constructor.
21
     * @param int $pageNumber
22
     * @param int $nbItems
23
     */
24
    public function __construct(int $pageNumber, int $nbItems = 0)
25
    {
26
        $this->pageNumber = max(0, $pageNumber);
27
        $this->nbItems = max(0, $nbItems);
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function getPageNumber(): int
34
    {
35
        return $this->pageNumber;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function count(): int
42
    {
43
        return $this->nbItems;
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function __toString(): string
50
    {
51
        return (string) $this->pageNumber;
52
    }
53
}
54