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

Scopes::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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