1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace App\Service\Note; |
||
6 | |||
7 | final class Find extends Base |
||
8 | { |
||
9 | 1 | /** |
|
10 | * @return array<string> |
||
11 | 1 | */ |
|
12 | public function getAll(): array |
||
13 | { |
||
14 | 2 | return $this->noteRepository->getAllNotes(); |
|
15 | } |
||
16 | |||
17 | /** |
||
18 | * @return array<string> |
||
19 | */ |
||
20 | 2 | public function getNotesByPage( |
|
21 | 1 | int $page, |
|
22 | int $perPage, |
||
23 | 2 | ?string $name, |
|
24 | 1 | ?string $description |
|
25 | ): array { |
||
26 | if ($page < 1) { |
||
27 | 2 | $page = 1; |
|
28 | 2 | } |
|
29 | if ($perPage < 1) { |
||
30 | $perPage = self::DEFAULT_PER_PAGE_PAGINATION; |
||
31 | } |
||
32 | |||
33 | return $this->noteRepository->getNotesByPage( |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
34 | $page, |
||
35 | 3 | $perPage, |
|
36 | $name, |
||
37 | 3 | $description |
|
38 | 3 | ); |
|
39 | } |
||
40 | |||
41 | public function getOne(int $noteId): object |
||
42 | { |
||
43 | 2 | if (self::isRedisEnabled() === true) { |
|
44 | $note = $this->getOneFromCache($noteId); |
||
45 | } else { |
||
46 | 2 | $note = $this->getOneFromDb($noteId)->toJson(); |
|
47 | } |
||
48 | 2 | ||
49 | return $note; |
||
50 | } |
||
51 | |||
52 | public function search(string $notesName): array |
||
53 | { |
||
54 | return $this->noteRepository->search($notesName); |
||
55 | } |
||
56 | } |
||
57 |