| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function switchDomain(User $user, Domain $newDomain): void |
||
| 34 | { |
||
| 35 | $mapToId = function(DataObject $object) { |
||
| 36 | return $object->getId(); |
||
| 37 | }; |
||
| 38 | |||
| 39 | $allowed = in_array($newDomain->getId(), array_map($mapToId, self::getAllowedDomains($user))); |
||
|
|
|||
| 40 | |||
| 41 | if ($allowed) { |
||
| 42 | WebRequest::setActiveDomain($newDomain); |
||
| 43 | } |
||
| 44 | else { |
||
| 45 | throw new AccessDeniedException(); |
||
| 46 | } |
||
| 48 | } |