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

GuardHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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