Completed
Push — master ( 1dfc8b...437320 )
by Arthur
02:02
created

GuardHandler::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3
1
<?php
2
3
namespace Larapie\Guard\Handlers;
4
5
use Larapie\Guard\Contracts\GuardContract;
6
7
class GuardHandler
8
{
9
    /**
10
     * @var GuardContract[]
11
     */
12
    protected $guards = [];
13
14
    /**
15
     * GuardDispatcher constructor.
16
     * @param $guards
17
     */
18 5
    public function __construct(array $guards)
19
    {
20 5
        $this->guards = $guards;
21 5
    }
22
23 5
    public function handle()
24
    {
25 5
        foreach ($this->guards as $guard) {
26 5
            if ($guard->condition()) {
27 5
                throw $guard->exception();
28
            }
29
        }
30 2
    }
31
}
32