| Total Complexity | 6 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class BouncerFactory |
||
| 21 | { |
||
| 22 | public static function create(Rule $rule, array|string $subjects = []): BouncerInterface |
||
| 23 | { |
||
| 24 | if (is_string($subjects)) { |
||
|
|
|||
| 25 | $trimmed = []; |
||
| 26 | foreach (explode(';', $subjects) as $subject) { |
||
| 27 | if (!empty($subject)) { |
||
| 28 | $trimmed[] = trim($subject); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | $subjects = $trimmed; |
||
| 32 | } |
||
| 33 | return match ($rule) { |
||
| 34 | Rule::ALLOW => new AllowList($subjects), |
||
| 35 | Rule::DENY => new DenyList($subjects), |
||
| 36 | }; |
||
| 37 | } |
||
| 38 | |||
| 39 | public static function createAllow(array|string $subjects = []): BouncerInterface |
||
| 42 | } |
||
| 43 | |||
| 44 | public static function createDeny(array|string $subjects = []): BouncerInterface |
||
| 49 |