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

RetrievalByUsername   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getRetrievalFields() 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 RetrievalByUsername.
21
 *
22
 * @author Melech Mizrachi
23
 */
24
class RetrievalByUsername implements Contract
25
{
26
    /**
27
     * @param non-empty-string $username The username
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
28
     */
29
    public function __construct(
30
        protected string $username,
31
    ) {
32
    }
33
34
    /**
35
     * @inheritDoc
36
     *
37
     * @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...
38
     *
39
     * @psalm-suppress LessSpecificImplementedReturnType
40
     */
41
    public function getRetrievalFields(string $user): array
42
    {
43
        return [
44
            $user::getUsernameField() => $this->username,
45
        ];
46
    }
47
}
48