| Total Complexity | 6 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class GeoRoutesMiddleware |
||
| 10 | { |
||
| 11 | use DeterminesGeoAccess; |
||
|
|
|||
| 12 | |||
| 13 | protected $countries; |
||
| 14 | protected $strategy; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Handle an incoming request. |
||
| 18 | * |
||
| 19 | * @param \Illuminate\Http\Request $request |
||
| 20 | * @param \Closure $next |
||
| 21 | * @param string $strategy |
||
| 22 | * @param string $countries |
||
| 23 | * @param string|null $callback |
||
| 24 | * @return mixed |
||
| 25 | */ |
||
| 26 | 15 | public function handle(Request $request, Closure $next, string $strategy, string $countries, string $callback = null) |
|
| 27 | { |
||
| 28 | 15 | $this->countries = explode('&', $countries); |
|
| 29 | 15 | $this->strategy = $strategy; |
|
| 30 | |||
| 31 | 15 | if ($this->shouldHaveAccess($request)) { |
|
| 32 | 3 | return $next($request); |
|
| 33 | } |
||
| 34 | |||
| 35 | 12 | if ($callback && $callback = unserialize($callback)) { |
|
| 36 | 7 | return call_user_func_array($callback[0], $callback[1] ?? []); |
|
| 37 | } |
||
| 38 | |||
| 39 | 5 | return abort(401); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the countries. |
||
| 44 | * |
||
| 45 | * @return string[] |
||
| 46 | */ |
||
| 47 | 15 | public function getCountries() |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get the strategy. |
||
| 54 | * |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | 15 | public function getStrategy() |
|
| 62 |