| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 55.56% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class FederationPolicy |
||
| 12 | { |
||
| 13 | use HandlesAuthorization; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Create a new policy instance. |
||
| 17 | * @param User $user |
||
| 18 | * @param $ability |
||
| 19 | * @return bool |
||
| 20 | */ |
||
| 21 | 1 | public function before(User $user, $ability) |
|
|
|
|||
| 22 | { |
||
| 23 | 1 | if ($user->isSuperAdmin()) { |
|
| 24 | return true; |
||
| 25 | } |
||
| 26 | 1 | return null; |
|
| 27 | } |
||
| 28 | |||
| 29 | // Only SuperAdmin should be able to create Federations |
||
| 30 | public function create(User $user) |
||
| 31 | { |
||
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | // Only SuperAdmin should be able to store Federations |
||
| 36 | public function store(User $user, Federation $federation) |
||
| 37 | { |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | |||
| 41 | // Only SuperAdmin should be able to delete Federations |
||
| 42 | public function delete(User $user, Federation $federation) |
||
| 43 | { |
||
| 44 | return false; |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | public function edit(User $user, Federation $federation) |
|
| 48 | { |
||
| 49 | 1 | if ($user->federationOwned == null) |
|
| 50 | 1 | return false; |
|
| 51 | |||
| 52 | 1 | return $user->federationOwned->id == $federation->id; |
|
| 53 | } |
||
| 54 | |||
| 55 | 1 | public function update(User $user, Federation $federation) |
|
| 61 | } |
||
| 62 | |||
| 63 | |||
| 64 | } |
||
| 65 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.