Passed
Push — master ( b3e4ed...666180 )
by Anthony
03:07 queued 01:33
created

GuardDispatcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 5 3
A __construct() 0 3 1
1
<?php
2
3
namespace Larapie\Guard\Dispatcher;
4
5
use Larapie\Guard\Contracts\GuardContract;
6
7
class GuardDispatcher
8
{
9
    /**
10
     * @var GuardContract[]
11
     */
12
    protected $guards = [];
13
14
    /**
15
     * GuardDispatcher constructor.
16
     * @param $guards
17
     */
18
    public function __construct(array $guards)
19
    {
20
        $this->guards = $guards;
21
    }
22
23
    public function dispatch()
24
    {
25
        foreach ($this->guards as $guard) {
26
            if ($guard->condition()) {
27
                throw $guard->exception();
28
            }
29
        }
30
    }
31
}
32