Test Failed
Pull Request — master (#23)
by
unknown
10:17
created

Paginator   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 91
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getPaginator() 0 3 1
A __construct() 0 3 1
A getPerPage() 0 3 1
A getTotal() 0 3 1
A getLastPage() 0 3 1
A getUrl() 0 3 1
A getCurrentPage() 0 3 1
A getCount() 0 3 1
1
<?php
2
3
namespace Rexlabs\Laravel\Smokescreen\Pagination;
4
5
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
6
use Rexlabs\Smokescreen\Pagination\PaginatorInterface;
0 ignored issues
show
Bug introduced by
The type Rexlabs\Smokescreen\Pagination\PaginatorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Provides a bridge between Laravel's LengthAwarePaginator and Smokescreen's pagination interface.
10
 * Code is heavily based on `thephpleague/fractal` package.
11
 */
12
class Paginator implements PaginatorInterface
13
{
14
    /**
15
     * The paginator instance.
16
     *
17
     * @var \Illuminate\Contracts\Pagination\LengthAwarePaginator
18
     */
19
    protected $paginator;
20
21
    /**
22
     * Create a new illuminate pagination adapter.
23
     *
24
     * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
25
     *
26
     * @return void
27
     */
28
    public function __construct(LengthAwarePaginator $paginator)
29
    {
30
        $this->paginator = $paginator;
31
    }
32
33
    /**
34
     * Get the current page.
35
     *
36
     * @return int
37
     */
38
    public function getCurrentPage(): int
39
    {
40
        return $this->paginator->currentPage();
41
    }
42
43
    /**
44
     * Get the last page.
45
     *
46
     * @return int
47
     */
48
    public function getLastPage(): int
49
    {
50
        return $this->paginator->lastPage();
51
    }
52
53
    /**
54
     * Get the total.
55
     *
56
     * @return int
57
     */
58
    public function getTotal(): int
59
    {
60
        return $this->paginator->total();
61
    }
62
63
    /**
64
     * Get the count.
65
     *
66
     * @return int
67
     */
68
    public function getCount(): int
69
    {
70
        return $this->paginator->count();
71
    }
72
73
    /**
74
     * Get the number per page.
75
     *
76
     * @return int
77
     */
78
    public function getPerPage(): int
79
    {
80
        return $this->paginator->perPage();
81
    }
82
83
    /**
84
     * Get the url for the given page.
85
     *
86
     * @param int $page
87
     *
88
     * @return string
89
     */
90
    public function getUrl($page): string
91
    {
92
        return $this->paginator->url($page);
93
    }
94
95
    /**
96
     * Get the paginator instance.
97
     *
98
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
99
     */
100
    public function getPaginator(): LengthAwarePaginator
101
    {
102
        return $this->paginator;
103
    }
104
}
105