Completed
Pull Request — master (#304)
by Benoît
03:33
created

IlluminatePaginatorAdapter::getTotal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 2 Features 0
Metric Value
c 2
b 2
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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
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
        return $this->paginator->count();
81
    }
82
83
    /**
84
     * Get the number per page.
85
     *
86
     * @return int
87
     */
88 1
    public function getPerPage()
89
    {
90 1
        return $this->paginator->perPage();
91
    }
92
93
    /**
94
     * Get the url for the given page.
95
     *
96
     * @param int $page
97
     *
98
     * @return string
99
     */
100 1
    public function getUrl($page)
101
    {
102 1
        return $this->paginator->url($page);
103
    }
104
105
    /**
106
     * Get the paginator instance.
107
     *
108
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
109
     */
110 1
    public function getPaginator()
111
    {
112 1
        return $this->paginator;
113
    }
114
}
115