Test Failed
Push — dev ( ccede5...b27119 )
by Herberto
13:46
created

OauthClientRepository::getClientEntity()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 4
nc 3
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Acme\App\Infrastructure\Auth\Authentication\Oauth;
6
7
use League\OAuth2\Server\Entities\ClientEntityInterface;
8
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
9
10
final class OauthClientRepository implements ClientRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getClientEntity(
16
        $clientIdentifier,
17
        $grantType = null,
18
        $clientSecret = null,
19
        $mustValidateSecret = true
20
    ): ?ClientEntityInterface {
21
        $appClient = $this->appClientRepository->findActive($clientIdentifier);
0 ignored issues
show
Bug introduced by
The property appClientRepository does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
        if ($appClient === null) {
23
            return null;
24
        }
25
        if ($mustValidateSecret && !hash_equals($appClient->getSecret(), (string) $clientSecret)) {
26
            return null;
27
        }
28
        $oauthClient = new OauthClient($clientIdentifier, $appClient->getName(), $appClient->getRedirect());
29
30
        return $oauthClient;
31
    }
32
}
33