IlluminatePaginatorAdapter   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 97
ccs 18
cts 19
cp 0.9474
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 8 2
A getPerPage() 0 4 1
A getUrl() 0 4 1
A getPaginator() 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
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
15
16
/**
17
 * A paginator adapter for illuminate/pagination.
18
 *
19
 * @author Maxime Beaudoin <[email protected]>
20
 * @author Marc Addeo <[email protected]>
21
 */
22
class IlluminatePaginatorAdapter implements PaginatorInterface
23
{
24
    /**
25
     * The paginator instance.
26
     *
27
     * @var \Illuminate\Contracts\Pagination\LengthAwarePaginator
28
     */
29
    protected $paginator;
30
31
    /**
32
     * Create a new illuminate pagination adapter.
33
     *
34
     * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
35
     *
36
     * @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...
37
     */
38 1
    public function __construct(LengthAwarePaginator $paginator)
39
    {
40 1
        $this->paginator = $paginator;
41 1
    }
42
43
    /**
44
     * Get the current page.
45
     *
46
     * @return int
47
     */
48 1
    public function getCurrentPage()
49
    {
50 1
        return $this->paginator->currentPage();
51
    }
52
53
    /**
54
     * Get the last page.
55
     *
56
     * @return int
57
     */
58 1
    public function getLastPage()
59
    {
60 1
        return $this->paginator->lastPage();
61
    }
62
63
    /**
64
     * Get the total.
65
     *
66
     * @return int
67
     */
68 1
    public function getTotal()
69
    {
70 1
        return $this->paginator->total();
71
    }
72
73
    /**
74
     * Get the count.
75
     *
76
     * @return int
77
     */
78 1
    public function getCount()
79
    {
80 1
        if (method_exists($this->paginator, 'count')) {
81
            return $this->paginator->count();
82
        }
83
84 1
        return count($this->paginator->items());
85
    }
86
87
    /**
88
     * Get the number per page.
89
     *
90
     * @return int
91
     */
92 1
    public function getPerPage()
93
    {
94 1
        return $this->paginator->perPage();
95
    }
96
97
    /**
98
     * Get the url for the given page.
99
     *
100
     * @param int $page
101
     *
102
     * @return string
103
     */
104 1
    public function getUrl($page)
105
    {
106 1
        return $this->paginator->url($page);
107
    }
108
109
    /**
110
     * Get the paginator instance.
111
     *
112
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
113
     */
114 1
    public function getPaginator()
115
    {
116 1
        return $this->paginator;
117
    }
118
}
119