| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class RoleBelongsToGroup implements Rule |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var RoleRepository |
||
| 19 | */ |
||
| 20 | private $roleRepository; |
||
| 21 | /** |
||
| 22 | * @var Authentication |
||
| 23 | */ |
||
| 24 | private $authentication; |
||
| 25 | |||
| 26 | 24 | public function __construct(RoleRepository $roleRepository, Authentication $authentication) |
|
| 30 | 24 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @inheritDoc |
||
| 34 | */ |
||
| 35 | 24 | public function passes($attribute, $value) |
|
| 36 | { |
||
| 37 | 24 | $role = $this->roleRepository->getById($value); |
|
| 38 | 24 | return $this->group()->id() === $role->groupId(); |
|
| 39 | } |
||
| 40 | |||
| 41 | 24 | protected function group() |
|
| 42 | { |
||
| 43 | 24 | return $this->authentication->getGroup(); |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @inheritDoc |
||
| 48 | */ |
||
| 49 | 4 | public function message() |
|
| 52 | } |
||
| 53 | } |