Failed Conditions
Push — master ( 7c3864...930f9b )
by Florent
14:15
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\ServerBundle\Tests\TestBundle\Entity;
15
16
use OAuth2Framework\Component\Core\ResourceOwner\ResourceOwnerId;
17
use OAuth2Framework\Component\Core\UserAccount\UserAccountId;
18
use OAuth2Framework\Component\ResourceOwnerPasswordCredentialsGrant\ResourceOwnerPasswordCredentialManager as ResourceOwnerPasswordCredentialManagerInterface;
19
20
class ResourceOwnerPasswordCredentialManager implements ResourceOwnerPasswordCredentialManagerInterface
21
{
22
    /**
23
     * @var ResourceOwnerId[]
24
     */
25
    private $usernameAndPasswords;
26
27
    public function __construct()
28
    {
29
        $this->usernameAndPasswords = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array('password.1' => ne...serAccountId('john.1')) of type array<string,object<OAut...ount\\UserAccountId>"}> is incompatible with the declared type array<integer,object<OAu...Owner\ResourceOwnerId>> of property $usernameAndPasswords.

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...
30
            'password.1' => new UserAccountId('john.1'),
31
        ];
32
    }
33
34
    public function findResourceOwnerIdWithUsernameAndPassword(string $username, string $password): ?ResourceOwnerId
35
    {
36
        if (!array_key_exists($password, $this->usernameAndPasswords)) {
37
            return null;
38
        }
39
        if ($this->usernameAndPasswords[$password]->getValue() !== $username) {
40
            return null;
41
        }
42
43
        return $this->usernameAndPasswords[$password];
44
    }
45
}
46