Page::getPageNumber()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
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