Completed
Push — master ( e4a954...682c69 )
by Iman
03:08
created

EloquentConditionApplier   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A startGuarding() 0 4 2
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
class EloquentConditionApplier
6
{
7
    private $event;
8
9
    private $modelClass;
10
11
    /**
12
     * RouteConditionApplier constructor.
13
     *
14
     * @param $event
15
     * @param $modelClass
16
     * @return \Imanghafoori\HeyMan\EloquentConditionApplier
17
     */
18 9
    public function init($event, $modelClass)
19
    {
20 9
        $this->event = $event;
21 9
        $this->modelClass = $modelClass;
22
23 9
        return $this;
24
    }
25
26
    /**
27
     * @param $callback
28
     */
29 9
    public function startGuarding(callable $callback)
30
    {
31 9
        foreach ($this->modelClass as $model) {
32 9
            $model::{$this->event}($callback);
33
        }
34 9
    }
35
36
37
}