Scope   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
namespace Orkhanahmadov\EloquentRepository\Repository\Eloquent\Criteria;
4
5
use Illuminate\Support\Arr;
6
use Illuminate\Database\Eloquent\Builder;
7
use Orkhanahmadov\EloquentRepository\Repository\Criteria\Criterion;
8
9
class Scope implements Criterion
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $scopes;
15
16
    /**
17
     * Scope constructor.
18
     * @param mixed ...$scopes
19
     */
20
    public function __construct(...$scopes)
21
    {
22
        $this->scopes = Arr::flatten($scopes);
23
    }
24
25
    /**
26
     * @param Builder|mixed $model
27
     *
28
     * @return Builder|mixed
29
     */
30
    public function apply($model)
31
    {
32
        foreach ($this->scopes as $scope) {
33
            $model = $model->{$scope}();
34
        }
35
36
        return $model;
37
    }
38
}
39