Completed
Push — master ( 8e8eee...0073f8 )
by wen
12:40
created

Applies   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 9 2
A apply() 0 8 2
1
<?php
2
3
namespace Sco\Admin\View\Extensions;
4
5
use Closure;
6
use Illuminate\Database\Eloquent\Builder;
7
8
class Applies extends Extension
9
{
10
    public function add($value)
11
    {
12
        if (!($value instanceof Closure)) {
13
            throw new \InvalidArgumentException('apply value must be \\Closure');
14
        }
15
16
        $this->push($value);
17
        return $this;
18
    }
19
20
    public function apply(Builder $query)
21
    {
22
        $this->each(function ($apply) use ($query) {
23
            if (is_callable($apply)) {
24
                call_user_func($apply, $query);
25
            }
26
        });
27
    }
28
}
29