Pagination::__construct()   B
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 8
c 2
b 0
f 0
nc 9
nop 1
dl 0
loc 12
ccs 10
cts 10
cp 1
crap 5
rs 8.8571
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