Completed
Push — master ( 6d0dd7...30241b )
by Sebastian
02:33
created

src/macros/simplePaginate.php (1 issue)

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
use Illuminate\Support\Collection;
4
use Illuminate\Pagination\Paginator;
5
6
/*
7
 * Paginate the collection into a simple paginator
8
 *
9
 * @param int $perPage
10
 * @param int $page
11
 * @param string $pageName
12
 *
13
 * @return \Illuminate\Contracts\Pagination\Paginator
14
 */
15
Collection::macro('simplePaginate', function (int $perPage = 15, string $pageName = 'page', int $page = null, array $options = []): Paginator {
16
    $page = $page ?: Paginator::resolveCurrentPage($pageName);
17
18
    $results = $this->slice(($page - 1) * $perPage)->take($perPage + 1);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
19
20
    $options += [
21
        'path' => Paginator::resolveCurrentPath(),
22
        'pageName' => $pageName,
23
    ];
24
25
    return new Paginator($results, $perPage, $page, $options);
26
});
27