UserRepository::getUserEntityByUserCredentials()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 2
nc 2
nop 4
crap 6
1
<?php
2
3
namespace CodexShaper\OAuth2\Server\Repositories;
4
5
use CodexShaper\OAuth2\Server\Entities\User as UserEntity;
6
use CodexShaper\OAuth2\Server\Model;
7
use League\OAuth2\Server\Entities\ClientEntityInterface;
8
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
9
10
class UserRepository implements UserRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getUserEntityByUserCredentials(
16
        $username,
17
        $password,
18
        $grantType,
19
        ClientEntityInterface $clientEntity
20
    )
21
    {
22
        $authIdentifier = Model::verifyUserForGrant($username, $password, $grantType, $clientEntity);
23
24
        if (!$authIdentifier) {
25
            return;
26
        }
27
28
        return new UserEntity($authIdentifier);
0 ignored issues
show
Documentation introduced by
$authIdentifier is of type object<CodexShaper\OAuth2\Server\Models\User>, but the function expects a string|integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
    }
30
}
31