UserShowUseCase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A run() 0 11 3
1
<?php
2
declare(strict_types=1);
3
4
namespace N1215\SimpleAdr\Domain;
5
6
/**
7
 * Get user detail
8
 * @package N1215\SimpleAdr\Domain
9
 */
10
class UserShowUseCase
11
{
12
    /**
13
     * @var User[]
14
     */
15
    private $users;
16
17
    /**
18
     * @param User[] $users
19
     */
20 1
    public function __construct(User ...$users)
21
    {
22 1
        $this->users = $users;
0 ignored issues
show
Documentation Bug introduced by
It seems like $users of type array<integer,array<inte...impleAdr\Domain\User>>> is incompatible with the declared type array<integer,object<N12...SimpleAdr\Domain\User>> of property $users.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
    }
24
25
    /**
26
     * @param int|null $rawUserId
27
     * @return User|null
28
     */
29 1
    public function run(?int $rawUserId): ?User
30
    {
31 1
        $userId = new UserId($rawUserId);
32 1
        foreach ($this->users as $user) {
33 1
            if ($user->getId()->equals($userId)) {
34 1
                return $user;
35
            }
36
        }
37
38 1
        return null;
39
    }
40
}
41