Passed
Push — master ( d3cc39...f2a84f )
by Melech
03:59
created

RetrievalByIdAndUsername   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
dl 0
loc 24
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRetrievalFields() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Auth\Data\Retrieval;
15
16
use Valkyrja\Auth\Data\Retrieval\Contract\Retrieval as Contract;
17
use Valkyrja\Auth\Entity\Contract\User;
18
19
/**
20
 * Class RetrievalByIdAndUsername.
21
 *
22
 * @author Melech Mizrachi
23
 */
24
class RetrievalByIdAndUsername implements Contract
25
{
26
    /**
27
     * @param non-empty-string|int $id       The id
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string|int at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string|int.
Loading history...
28
     * @param non-empty-string     $username The username
29
     */
30
    public function __construct(
31
        protected string|int $id,
32
        protected string $username,
33
    ) {
34
    }
35
36
    /**
37
     * @inheritDoc
38
     *
39
     * @param class-string<User> $user The user
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<User> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<User>.
Loading history...
40
     *
41
     * @psalm-suppress LessSpecificImplementedReturnType
42
     */
43
    public function getRetrievalFields(string $user): array
44
    {
45
        return [
46
            $user::getIdField()       => $this->id,
47
            $user::getUsernameField() => $this->username,
48
        ];
49
    }
50
}
51