Completed
Push — master ( 785bde...8b4d11 )
by Freek
01:29
created

src/Macros/Paginate.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
{
19
    public function __invoke()
20
    {
21
        return function (int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []): LengthAwarePaginator {
22
            $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
23
24
            $results = $this->forPage($page, $perPage);
0 ignored issues
show
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...
25
26
            $total = $total ?: $this->count();
0 ignored issues
show
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...
27
28
            $options += [
29
                'path' => LengthAwarePaginator::resolveCurrentPath(),
30
                'pageName' => $pageName,
31
            ];
32
33
            return new LengthAwarePaginator($results, $total, $perPage, $page, $options);
34
        };
35
    }
36
}
37