Conditions | 1 |
Paths | 1 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
16 | 4 | public function update(RoleInterface $role): bool |
|
17 | { |
||
18 | 4 | $updated = $this->query()->find($role->getId()); |
|
19 | |||
20 | 4 | $updated->fill([ |
|
21 | 4 | 'name' => $role->getName(), |
|
22 | 4 | 'guard_name' => $role->getGuardName(), |
|
23 | 4 | ])->save(); |
|
24 | |||
25 | 4 | $role->setCreatedAt($updated->created_at); |
|
26 | 4 | $role->setUpdatedAt($updated->updated_at); |
|
27 | |||
28 | 4 | $this->syncPermissions($updated, $role); |
|
|
|||
29 | |||
30 | 4 | event(new RoleUpdated($role, count($updated->getChanges()) >= 1)); |
|
31 | |||
32 | 4 | return count($updated->getChanges()) >= 1; |
|
33 | } |
||
34 | } |
||
35 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.