Conditions | 6 |
Paths | 9 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function update($input, int $noteId) |
||
12 | { |
||
13 | $note = $this->getOneFromDb($noteId); |
||
14 | $data = json_decode(json_encode($input), false); |
||
15 | if (!isset($data->name) && !isset($data->description)) { |
||
16 | throw new NoteException('Enter the data to update the note.', 400); |
||
17 | } |
||
18 | if (isset($data->name)) { |
||
19 | $note->name = self::validateNoteName($data->name); |
||
20 | } |
||
21 | if (isset($data->description)) { |
||
22 | $note->description = $data->description; |
||
23 | } |
||
24 | $notes = $this->noteRepository->updateNote($note); |
||
25 | if (self::isRedisEnabled() === true) { |
||
26 | $this->saveInCache($notes->id, $notes); |
||
27 | } |
||
28 | |||
29 | return $notes; |
||
30 | } |
||
31 | } |
||
32 |