| Total Complexity | 7 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 93.75% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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( |
||
|
|
|||
| 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 |
||
| 55 | } |
||
| 56 | } |
||
| 57 |