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

PageScope   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 32
ccs 0
cts 6
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
A __construct() 0 4 1
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