| Conditions | 5 |
| Paths | 16 |
| Total Lines | 26 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 42 | public function run($userId, $password = null, $name = null, $email = null) |
||
| 43 | { |
||
| 44 | $attributes = []; |
||
| 45 | |||
| 46 | if ($password) { |
||
| 47 | $attributes['password'] = Hash::make($password); |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($name) { |
||
| 51 | $attributes['name'] = $name; |
||
| 52 | } |
||
| 53 | |||
| 54 | if ($email) { |
||
| 55 | $attributes['email'] = $email; |
||
| 56 | } |
||
| 57 | |||
| 58 | // check if data is empty |
||
| 59 | if (!$attributes) { |
||
|
|
|||
| 60 | throw new UpdateResourceFailedException('Inputs are empty.'); |
||
| 61 | } |
||
| 62 | |||
| 63 | // updating the attributes |
||
| 64 | $user = $this->userRepository->update($attributes, $userId); |
||
| 65 | |||
| 66 | return $user; |
||
| 67 | } |
||
| 68 | |||
| 71 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.