Base   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 13
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A scopePage() 0 4 3
1
<?php
2
3
namespace Siak\Tontine\Model;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Base extends Model
9
{
10
    /**
11
     * @param  Builder  $query
12
     * @param  int  $page
13
     * @param  int  $limit
14
     *
15
     * @return Builder
16
     */
17
    public function scopePage(Builder $query, int $page, int $limit): Builder
18
    {
19
        return $page < 1 || $limit < 1 ? $query :
0 ignored issues
show
Bug Best Practice introduced by
The expression return $page < 1 || $lim...kip($limit * $page - 1) could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
20
            $query->take($limit)->skip($limit * ($page - 1));
21
    }
22
}
23