| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 23 | 
| Code Lines | 13 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 16 | 
| CRAP Score | 5 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 21 | 7 | public function handle($request, Closure $next, $guard = null) | |
| 22 |     { | ||
| 23 | 7 |         if (app()->environment(config('release-protection.email.envs.' . $guard, config('release-protection.email.envs.default')))) { | |
|  | |||
| 24 | 7 | $user = Auth::guard($guard)->user(); | |
| 25 | 7 |             if (!$user) { | |
| 26 | 2 | abort( | |
| 27 | 2 |                     config('release-protection.email.status.not_logged.' . $guard, config('release-protection.email.status.not_logged.default')), | |
| 28 | 2 |                     __(config('release-protection.email.msg.not_logged.' . $guard, config('release-protection.email.msg.not_logged.default'))) | |
| 29 | 2 | ); | |
| 30 | } | ||
| 31 | |||
| 32 | 5 |             $allowEmails = config('release-protection.email.emails.' . $guard, config('release-protection.email.emails.default')); | |
| 33 | 5 | $allowEmails = array_map(fn ($e) => trim(strtolower($e)), $allowEmails); | |
| 34 | |||
| 35 | 5 |             if (!$user->email || !in_array(strtolower($user->email), $allowEmails)) { | |
| 36 | 3 | abort( | |
| 37 | 3 |                     config('release-protection.email.status.restricted.' . $guard, config('release-protection.email.status.restricted.default')), | |
| 38 | 3 |                     __(config('release-protection.email.msg.restricted.' . $guard, config('release-protection.email.msg.restricted.default'))) | |
| 39 | 3 | ); | |
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | 2 | return $next($request); | |
| 44 | } | ||
| 46 |