PageScope::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\Database\Scopes;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Scope;
8
9
class PageScope implements Scope
10
{
11
    /**
12
     * @var int
13
     */
14
    private $page;
15
    /**
16
     * @var int
17
     */
18
    private $perPage;
19
20
    /**
21
     * PageScope constructor.
22
     * @param int $page
23
     * @param int $perPage
24
     */
25 13
    public function __construct(int $page, int $perPage)
26
    {
27 13
        $this->page = $page;
28 13
        $this->perPage = $perPage;
29 13
    }
30
31
    /**
32
     * Apply the scope to a given Eloquent query builder.
33
     *
34
     * @param \Illuminate\Database\Eloquent\Builder $builder
35
     * @param \Illuminate\Database\Eloquent\Model $model
36
     * @return void
37
     */
38 12
    public function apply(Builder $builder, Model $model)
39
    {
40 12
        $builder->forPage($this->page, $this->perPage);
41 12
    }
42
}
43