UserRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getUserEntityByUserCredentials() 0 14 2
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
        $authIdentifier = Model::verifyUserForGrant($username, $password, $grantType, $clientEntity);
22
23
        if (!$authIdentifier) {
24
            return;
25
        }
26
27
        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...
28
    }
29
}
30