NoteFinderRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findNoteById() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace App\Module\Note\Find\Repository;
4
5
use App\Infrastructure\Database\QueryFactory;
0 ignored issues
show
Bug introduced by
The type App\Infrastructure\Database\QueryFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use App\Module\Note\Data\NoteData;
7
8
readonly class NoteFinderRepository
9
{
10 37
    public function __construct(
11
        private QueryFactory $queryFactory,
12
    ) {
13 37
    }
14
15
    /**
16
     * Return note with given id if it exists
17
     * otherwise null.
18
     *
19
     * @param string|int $id
20
     *
21
     * @return NoteData
22
     */
23 25
    public function findNoteById(string|int $id): NoteData
24
    {
25 25
        $query = $this->queryFactory->selectQuery()->select(['*'])->from('note')->where(
26 25
            ['deleted_at IS' => null, 'id' => $id]
27 25
        );
28 25
        $noteRow = $query->execute()->fetch('assoc') ?: [];
29
30 25
        return new NoteData($noteRow);
31
    }
32
}
33