Find::search()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
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
The expression return $this->noteReposi...e, $name, $description) returns the type array<string,array|array<string,double|integer>> which is incompatible with the documented return type string[].
Loading history...
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