| Total Complexity | 3 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class RoleHasNoUsersAssigned implements Rule |
||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @var Role |
||
| 13 | */ |
||
| 14 | private $roleRepository; |
||
| 15 | |||
| 16 | 4 | public function __construct(Role $roleRepository) |
|
| 17 | { |
||
| 18 | 4 | $this->roleRepository = $roleRepository; |
|
| 19 | 4 | } |
|
| 20 | |||
| 21 | /** |
||
| 22 | * @inheritDoc |
||
| 23 | */ |
||
| 24 | 4 | public function passes($attribute, $value) |
|
| 25 | { |
||
| 26 | 4 | $role = $this->roleRepository->getById($value); |
|
| 27 | 4 | return $role->users()->count() === 0; |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @inheritDoc |
||
| 32 | */ |
||
| 33 | 1 | public function message() |
|
| 36 | } |
||
| 37 | } |