HasQueryPagination::paginate()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Reviewsio\Endpoints;
4
5
use Illuminate\Pagination\Paginator;
6
7
trait HasQueryPagination
8
{
9
    use HasGetQuery;
10
11 2
    public function paginate(int $perPage = 15, ?int $page = null, string $pageName = 'page'): static
12
    {
13 2
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
14
15 2
        $this->addParameterToQuery('per_page', $perPage)
16 2
             ->addParameterToQuery('page', $page);
17
18 2
        return $this;
19
    }
20
}
21