Pagination::setPageCount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
1
<?php
2
namespace ApigilityClient\Resource;
3
4
final class Pagination
5
{
6
7
    const PAGE_SIZE   = 'page_size';
8
    const PAGE_COUNT  = 'page_count';
9
    const TOTAL_ITEMS = 'total_items';
10
11
    private $pageSize;
12
    private $pageCount;
13
    private $totalItems;
14
15 5
    public function __construct(array $data = null)
16
    {
17 5
        if (! empty($data)) {
18 5
            $pageSize   = (int) isset($data[self::PAGE_SIZE]) ? $data[self::PAGE_SIZE] : 0;
19 5
            $pageCount  = (int) isset($data[self::PAGE_COUNT]) ? $data[self::PAGE_COUNT] : 0;
20 5
            $totalItems = (int) isset($data[self::TOTAL_ITEMS]) ? $data[self::TOTAL_ITEMS] : 0;
21
22 5
            $this->setPageSize($pageSize)
23 5
                 ->setPageCount($pageCount)
24 5
                 ->setTotalItems($totalItems);
25 5
        }
26 5
    }
27
28 5
    public function setPageSize($input)
29
    {
30 5
        $input = (int) $input;
31 5
        $this->pageSize = $input;
32
33 5
        return $this;
34
    }
35
36 3
    public function getPageSize()
37
    {
38 3
        return $this->pageSize;
39
    }
40
41 5
    public function setPageCount($input)
42
    {
43 5
        $input = (int) $input;
44 5
        $this->pageCount = $input;
45
46 5
        return $this;
47
    }
48
49 1
    public function getPageCount()
50
    {
51 1
        return $this->pageCount;
52
    }
53
54 5
    public function setTotalItems($input)
55
    {
56 5
        $input = (int) $input;
57 5
        $this->totalItems = $input;
58
59 5
        return $this;
60
    }
61
62 1
    public function getTotalItems()
63
    {
64 1
        return $this->totalItems;
65
    }
66
67
}
68