| Conditions | 5 |
| Paths | 16 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | 2 | public function update(array $input, int $noteId): object |
|
| 13 | 2 | { |
|
| 14 | 1 | $note = $this->getOneFromDb($noteId); |
|
| 15 | $data = json_decode((string) json_encode($input), false); |
||
| 16 | 2 | if (isset($data->name)) { |
|
| 17 | 1 | $note->updateName(self::validateNoteName($data->name)); |
|
| 18 | } |
||
| 19 | 2 | if (isset($data->description)) { |
|
| 20 | $note->updateDescription($data->description); |
||
| 21 | 2 | } |
|
| 22 | 2 | $note->updateUpdatedAt(date('Y-m-d H:i:s')); |
|
| 23 | 2 | /** @var Note $notes */ |
|
| 24 | $response = $this->noteRepository->update($note); |
||
| 25 | 2 | if (self::isRedisEnabled() === true) { |
|
| 26 | 2 | $this->saveInCache($response->getId(), $response->toJson()); |
|
| 27 | } |
||
| 28 | if (self::isLoggerEnabled() === true) { |
||
| 29 | 2 | $this->loggerService->setInfo('The note with the ID ' . $response->getId() . ' has updated successfully.'); |
|
| 30 | } |
||
| 31 | |||
| 32 | return $response->toJson(); |
||
| 33 | } |
||
| 35 |