Completed
Pull Request — master (#303)
by
unknown
08:49
created

PhalconFrameworkPaginatorAdapter::getPerPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 5
ccs 0
cts 2
cp 0
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the League\Fractal package.
5
 *
6
 * (c) Phil Sturgeon <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Fractal\Pagination;
13
14
/**
15
 * A paginator adapter for PhalconPHP/pagination.
16
 *
17
 * @author Thien Tran <[email protected]>
18
 * 
19
 */
20
class PhalconFrameworkPaginatorAdapter implements PaginatorInterface
21
{
22
    /**
23
     * A slice of the result set to show in the pagination
24
     *
25
     * @var \Phalcon\Paginator\AdapterInterface
26
     */
27
    private $paginator;
28
29
    
30 1
    public function __construct($paginator)
31
    {
32 1
        $this->paginator = $paginator;
33 1
    }
34
35
    /**
36
     * Get the current page.
37
     *
38
     * @return int
39
     */
40 1
    public function getCurrentPage()
41
    {
42 1
        return $this->getPaginator()->current;
43
    }
44
45
    /**
46
     * Get the last page.
47
     *
48
     * @return int
49
     */
50 1
    public function getLastPage()
51
    {
52 1
        return $this->getPaginator()->last;
53
    }
54
55
    /**
56
     * Get the total.
57
     *
58
     * @return int
59
     */
60 1
    public function getTotal()
61
    {
62 1
        return $this->getPaginator()->total_items;
63
    }
64
65
    /**
66
     * Get the count.
67
     *
68
     * @return int
69
     */
70 1
    public function getCount()
71
    {
72 1
        return $this->getPaginator()->total_pages;
73
    }
74
75
    /**
76
     * Get the number per page.
77
     *
78
     * @return int
79
     */
80
    public function getPerPage()
81
    {
82
        return $this->paginator->getLimit();
83
84
    }
85
86
    /**
87
     * Get the next.
88
     *
89
     * @return int
90
     */ 
91
    public function getNext()
92
    {
93
        return $this->getPaginator()->next;
94
    }
95
96
    /**
97
     * Get the url for the given page.
98
     *
99
     * @param int $page
100
     *
101
     * @return string
102
     */
103
    public function getUrl($page)
104
    {
105
        throw new \Exception("NotYetImplementedException");
106
    }
107
108
    /**
109
     * Get the paginate object.
110
     * 
111
     * @return object
112
     */
113 1
    public function getPaginator()
114
    {
115
        
116 1
        return $this->paginator->getPaginate();
117
    }
118
}
119