Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function create($input) |
||
12 | { |
||
13 | $note = new \stdClass(); |
||
14 | $data = json_decode(json_encode($input), false); |
||
15 | if (!isset($data->name)) { |
||
16 | throw new NoteException('Invalid data: name is required.', 400); |
||
17 | } |
||
18 | $note->name = self::validateNoteName($data->name); |
||
19 | $note->description = null; |
||
20 | if (isset($data->description)) { |
||
21 | $note->description = $data->description; |
||
22 | } |
||
23 | $notes = $this->noteRepository->createNote($note); |
||
24 | if (self::isRedisEnabled() === true) { |
||
25 | $this->saveInCache($notes->id, $notes); |
||
26 | } |
||
27 | |||
28 | return $notes; |
||
29 | } |
||
30 | } |
||
31 |