UserShowUseCase::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 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