Completed
Push — master ( 650783...0c9838 )
by wen
15:06
created

Scopes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 10 2
A apply() 0 8 1
1
<?php
2
3
namespace Sco\Admin\Display\Extensions;
4
5
use Illuminate\Database\Eloquent\Builder;
6
7
class Scopes extends Extension
8
{
9
    public function add($value)
10
    {
11
        if (! is_array($value)) {
12
            $value = func_get_args();
13
        }
14
15
        $this->push($value);
16
17
        return $this;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function apply(Builder $query)
24
    {
25
        $this->each(function ($scope) use ($query) {
26
            $method = array_shift($scope);
27
            $parameters = $scope;
28
            call_user_func_array([$query, $method], $parameters);
29
        });
30
    }
31
}
32