| Total Complexity | 4 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 28.57% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait ControlsAccess |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Determines whether to allow or deny access. |
||
| 9 | * |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | protected $strategy; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The countries to apply the rule for. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $countries; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Allow access from the given countries. |
||
| 23 | * |
||
| 24 | * @param string ...$countries |
||
| 25 | * |
||
| 26 | * @return $this |
||
| 27 | */ |
||
| 28 | 112 | public function allowFrom(string ...$countries) |
|
| 29 | { |
||
| 30 | 112 | $this->strategy = 'allow'; |
|
| 31 | 112 | $this->countries = $countries; |
|
| 32 | |||
| 33 | 112 | return $this; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Deny access from the given countries. |
||
| 38 | * |
||
| 39 | * @param string ...$countries |
||
| 40 | * |
||
| 41 | * @return $this |
||
| 42 | */ |
||
| 43 | public function denyFrom(string ...$countries) |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Allow given countries. |
||
| 51 | * |
||
| 52 | * @return $this |
||
| 53 | */ |
||
| 54 | public function allow() |
||
| 55 | { |
||
| 56 | $this->strategy = 'allow'; |
||
| 57 | |||
| 58 | return $this; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Deny given countries. |
||
| 63 | * |
||
| 64 | * @return $this |
||
| 65 | */ |
||
| 66 | public function deny() |
||
| 71 | } |
||
| 72 | } |
||
| 73 |