Conditions | 8 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 8 |
Changes | 0 |
1 | <?php |
||
21 | 11 | public function handle(Request $request, Closure $next) |
|
22 | { |
||
23 | |||
24 | 11 | $link = $request->get('link'); |
|
25 | |||
26 | 11 | if($link->clickLimitReached()) { |
|
27 | 1 | throw new LinkClickLimitReachedException; |
|
28 | } |
||
29 | 10 | if($link->group && $link->group->clickLimitReached()) { |
|
30 | 1 | throw new LinkGroupClickLimitReachedException; |
|
31 | } |
||
32 | 9 | if($link->expired()) { |
|
33 | 3 | throw new LinkExpiredException; |
|
34 | } |
||
35 | |||
36 | 6 | if($link->group && $link->group->expired() && $link->expiry === null) { |
|
37 | 1 | throw new LinkGroupExpiredException; |
|
38 | } |
||
39 | |||
40 | 5 | Event::dispatch(new LinkClicked($link)); |
|
|
|||
41 | |||
42 | 5 | return $next($request); |
|
43 | } |
||
45 | } |