Completed
Pull Request — master (#303)
by
unknown
04:20
created

PhalconFrameworkPaginatorAdapter   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 68.42%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 9
c 3
b 1
f 2
lcom 1
cbo 0
dl 0
loc 102
ccs 13
cts 19
cp 0.6842
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCurrentPage() 0 4 1
A getLastPage() 0 4 1
A getTotal() 0 4 1
A getCount() 0 4 1
A getPerPage() 0 5 1
A getNext() 0 4 1
A getUrl() 0 4 1
A getPaginate() 0 5 1
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
    protected $paginator;
28
29
    /***
30
     *
31
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
32
     */
33 1
    public function __construct($paginator)
34
    {
35 1
        $this->paginator = $paginator;
36 1
    }
37
38
    /**
39
     * Get the current page.
40
     *
41
     * @return int
42
     */
43 1
    public function getCurrentPage()
44
    {
45 1
        return $this->getPaginate()->current;
46
    }
47
48
    /**
49
     * Get the last page.
50
     *
51
     * @return int
52
     */
53 1
    public function getLastPage()
54
    {
55 1
        return $this->getPaginate()->last;
56
    }
57
58
    /**
59
     * Get the total.
60
     *
61
     * @return int
62
     */
63 1
    public function getTotal()
64
    {
65 1
        return $this->getPaginate()->total_items;
66
    }
67
68
    /**
69
     * Get the count.
70
     *
71
     * @return int
72
     */
73 1
    public function getCount()
74
    {
75 1
        return $this->getPaginate()->total_pages;
76
    }
77
78
    /**
79
     * Get the number per page.
80
     *
81
     * @return int
82
     */
83
    public function getPerPage()
84
    {
85
        return $this->paginator->getLimit();
86
87
    }
88
89
    /**
90
     * Get the next.
91
     *
92
     * @return int
93
     */ 
94
    public function getNext()
95
    {
96
        return $this->getPaginate()->next;
97
    }
98
99
    /**
100
     * Get the url for the given page.
101
     *
102
     * @param int $page
103
     *
104
     * @return string
105
     */
106
    public function getUrl($page)
107
    {
108
        //PhalconPHP not yet
109
    }
110
111
    /**
112
     * Get the paginate object.
113
     * 
114
     * @return object
115
     */
116 1
    public function getPaginate()
117
    {
118
        
119 1
        return $this->paginator->getPaginate();
120
    }
121
}
122