Completed
Pull Request — master (#303)
by
unknown
02:17
created

PhalconFrameworkPaginatorAdapter::getPerPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
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->getPaginate();
33 1
    }
34
35
    /**
36
     * Get the current page.
37
     *
38
     * @return int
39
     */
40 1
    public function getCurrentPage()
41
    {
42 1
        return $this->paginator->current;
43
    }
44
45
    /**
46
     * Get the last page.
47
     *
48
     * @return int
49
     */
50 1
    public function getLastPage()
51
    {
52 1
        return $this->paginator->last;
53
    }
54
55
    /**
56
     * Get the total.
57
     *
58
     * @return int
59
     */
60 1
    public function getTotal()
61
    {
62 1
        return $this->paginator->total_items;
63
    }
64
65
    /**
66
     * Get the count.
67
     *
68
     * @return int
69
     */
70 1
    public function getCount()
71
    {
72 1
        return $this->paginator->total_pages;
73
    }
74
75
    /**
76
     * Get the number per page.
77
     *
78
     * @return int
79
     */
80
    public function getPerPage()
81
    {
82
        // $this->paginator->items->count()
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
83
        // Because when we use raw sql have not this method
84
        return count($this->paginator->items);
85
    }
86
87
    /**
88
     * Get the next.
89
     *
90
     * @return int
91
     */ 
92
    public function getNext()
93
    {
94
        return $this->paginator->next;
95
    }
96
97
    /**
98
     * Get the url for the given page.
99
     *
100
     * @param int $page
101
     *
102
     * @return string
103
     */
104
    public function getUrl($page)
105
    {
106
        return $page;
107
    }
108
}
109