Completed
Pull Request — master (#161)
by
unknown
01:20
created

Paginate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 3
1
<?php
2
3
namespace Spatie\CollectionMacros\Macros;
4
5
use Illuminate\Pagination\LengthAwarePaginator;
6
7
/*
8
 * Paginate the given collection
9
 *
10
 * @param int $perPage
11
 * @param int $total
12
 * @param int $page
13
 * @param string $pageName
14
 *
15
 * @return \Illuminate\Pagination\LengthAwarePaginator
16
 */
17
class Paginate {
18
    public function __invoke() {
19
        return function (int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []): LengthAwarePaginator {
20
            $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
21
22
            $results = $this->forPage($page, $perPage);
0 ignored issues
show
Bug introduced by
The method forPage() does not seem to exist on object<Spatie\CollectionMacros\Macros\Paginate>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
24
            $total = $total ?: $this->count();
0 ignored issues
show
Bug introduced by
The method count() does not seem to exist on object<Spatie\CollectionMacros\Macros\Paginate>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26
            $options += [
27
                'path' => LengthAwarePaginator::resolveCurrentPath(),
28
                'pageName' => $pageName,
29
            ];
30
31
            return new LengthAwarePaginator($results, $total, $perPage, $page, $options);
32
        };
33
    }
34
}
35