Test Failed
Push — master ( 131fc3...3e7ec2 )
by Serhii
18:02 queued 12:24
created

PageScope::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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
    public function __construct(int $page, int $perPage)
26
    {
27
        $this->page = $page;
28
        $this->perPage = $perPage;
29
    }
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
    public function apply(Builder $builder, Model $model)
39
    {
40
        $builder->forPage($this->page, $this->perPage);
41
    }
42
}
43