| Total Complexity | 9 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 9 | final class Update extends Base |
||
| 10 | { |
||
| 11 | 3 | /** |
|
| 12 | * @param array<string> $input |
||
| 13 | 3 | */ |
|
| 14 | 3 | public function update(array $input, int $userId): object |
|
| 15 | 3 | { |
|
| 16 | 1 | $data = $this->validateUserData($input, $userId); |
|
| 17 | /** @var User $user */ |
||
| 18 | 2 | $user = $this->userRepository->update($data); |
|
| 19 | 2 | ||
| 20 | if (self::isRedisEnabled() === true) { |
||
| 21 | 1 | $this->saveInCache($user->getId(), $user->toJson()); |
|
| 22 | 1 | } |
|
| 23 | if (self::isLoggerEnabled() === true) { |
||
| 24 | 1 | $this->loggerService->setInfo('The user with the ID ' . $user->getId() . ' has updated successfully.'); |
|
| 25 | 1 | } |
|
| 26 | |||
| 27 | 1 | return $user->toJson(); |
|
| 28 | } |
||
| 29 | 1 | ||
| 30 | 1 | /** |
|
| 31 | 1 | * @param array<string> $input |
|
| 32 | */ |
||
| 33 | 1 | private function validateUserData(array $input, int $userId): User |
|
| 50 | } |
||
| 51 | } |
||
| 52 |