ClientRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 19
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getClientEntity() 0 13 6
1
<?php
2
3
namespace AdvancedLearning\Oauth2Server\Repositories;
4
5
use AdvancedLearning\Oauth2Server\Entities\ClientEntity;
6
use function hash_equals;
7
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
8
use const PHP_EOL;
9
10
class ClientRepository implements ClientRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true)
16
    {
17
        $client = \AdvancedLearning\Oauth2Server\Models\Client::get()->filter([
18
           'Identifier' => $clientIdentifier
19
        ])->first();
20
21
22
        if ($mustValidateSecret && $client && !hash_equals($client->Secret, $clientSecret)) {
23
            $client = null;
24
        }
25
26
        return $client && $client->hasGrantType($grantType) ? new ClientEntity($clientIdentifier, $client->Name, 'something') : null;
27
    }
28
}
29