Passed
Pull Request — master (#33)
by Serhii
04:40
created

PageScope   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 33
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
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
    /**
13
     * @var int
14
     */
15
    private $page;
16
    /**
17
     * @var int
18
     */
19
    private $perPage;
20
21
    /**
22
     * PageScope constructor.
23
     * @param int $page
24
     * @param int $perPage
25
     */
26 13
    public function __construct(int $page, int $perPage)
27
    {
28 13
        $this->page = $page;
29 13
        $this->perPage = $perPage;
30 13
    }
31
32
    /**
33
     * Apply the scope to a given Eloquent query builder.
34
     *
35
     * @param \Illuminate\Database\Eloquent\Builder $builder
36
     * @param \Illuminate\Database\Eloquent\Model $model
37
     * @return void
38
     */
39 12
    public function apply(Builder $builder, Model $model)
40
    {
41 12
        $builder->forPage($this->page, $this->perPage);
42 12
    }
43
}
44