PhalconFrameworkPaginatorAdapter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 93
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0

8 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 6 1
A getNext() 0 4 1
A getUrl() 0 4 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
 * @author Nikolaos Dimopoulos <[email protected]>
19
 *
20
 */
21
class PhalconFrameworkPaginatorAdapter implements PaginatorInterface
22
{
23
    /**
24
     * A slice of the result set to show in the pagination
25
     *
26
     * @var \stdClass
27
     */
28
    private $paginator;
29
30
    /**
31
     * PhalconFrameworkPaginatorAdapter constructor.
32
     *
33
     * @param \stdClass $paginator
34
     */
35 1
    public function __construct($paginator)
36
    {
37 1
        $this->paginator = $paginator;
38 1
    }
39
40
    /**
41
     * Get the current page.
42
     *
43
     * @return int
44
     */
45 1
    public function getCurrentPage()
46
    {
47 1
        return $this->paginator->current;
48
    }
49
50
    /**
51
     * Get the last page.
52
     *
53
     * @return int
54
     */
55 1
    public function getLastPage()
56
    {
57 1
        return $this->paginator->last;
58
    }
59
60
    /**
61
     * Get the total.
62
     *
63
     * @return int
64
     */
65 1
    public function getTotal()
66
    {
67 1
        return $this->paginator->total_items;
68
    }
69
70
    /**
71
     * Get the count.
72
     *
73
     * @return int
74
     */
75 1
    public function getCount()
76
    {
77 1
        return $this->paginator->total_pages;
78
    }
79
80
    /**
81
     * Get the number per page.
82
     *
83
     * @return int
84
     */
85 1
    public function getPerPage()
86
    {
87
        // $this->paginator->items->count()
88
        // Because when we use raw sql have not this method
89 1
        return count($this->paginator->items);
90
    }
91
92
    /**
93
     * Get the next.
94
     *
95
     * @return int
96
     */
97 1
    public function getNext()
98
    {
99 1
        return $this->paginator->next;
100
    }
101
102
    /**
103
     * Get the url for the given page.
104
     *
105
     * @param int $page
106
     *
107
     * @return string
108
     */
109
    public function getUrl($page)
110
    {
111
        return (string) $page;
112
    }
113
}
114