UserFinder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findUserById() 0 4 2
1
<?php
2
3
namespace App\Module\User\Find\Service;
4
5
use App\Module\User\Data\UserData;
6
use App\Module\User\Find\Repository\UserFinderRepository;
7
8
// Class cannot be readonly as it's mocked (doubled) in tests
9
class UserFinder
10
{
11 203
    public function __construct(
12
        private readonly UserFinderRepository $userFinderRepository,
13
    ) {
14 203
    }
15
16
    /**
17
     * @param string|int|null $id
18
     *
19
     * @return UserData
20
     */
21 157
    public function findUserById(string|int|null $id): UserData
22
    {
23
        // Find user in database and return object
24 157
        return $id ? new UserData($this->userFinderRepository->findUserById((int)$id)) : new UserData();
25
    }
26
}
27