| Conditions | 1 |
| Paths | 1 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 8 | public function update(UserInterface $user): bool |
|
| 17 | { |
||
| 18 | 8 | $updated = $this->query()->find($user->getId()); |
|
| 19 | |||
| 20 | 8 | $updated->fill([ |
|
| 21 | 8 | 'name' => $user->getName(), |
|
| 22 | 8 | 'language' => $user->getLanguage(), |
|
| 23 | 8 | 'email' => $user->getEmail(), |
|
| 24 | 8 | 'email_verified_at' => $user->getEmailVerifiedAt(), |
|
| 25 | 8 | 'password' => $user->getPassword(), |
|
| 26 | 8 | 'remember_token' => $user->getRememberToken(), |
|
| 27 | 8 | ])->save(); |
|
| 28 | |||
| 29 | 8 | $user->setCreatedAt($updated->created_at); |
|
| 30 | 8 | $user->setUpdatedAt($updated->updated_at); |
|
| 31 | |||
| 32 | 8 | $this->syncPermissions($updated, $user); |
|
|
|
|||
| 33 | 8 | $this->syncRoles($updated, $user); |
|
| 34 | |||
| 35 | 8 | event(new UserUpdated($user, count($updated->getChanges()) >= 1)); |
|
| 36 | |||
| 37 | 8 | return count($updated->getChanges()) >= 1; |
|
| 38 | } |
||
| 39 | } |
||
| 40 |
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.