Completed
Push — master ( 9628d6...a206dc )
by Derek Stephen
09:38
created

ClientRepository   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 60
rs 10
c 2
b 0
f 0
ccs 0
cts 22
cp 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A checkClientCredentials() 0 8 2
A isPublicClient() 0 4 1
A getClientDetails() 0 8 2
A getClientScope() 0 4 1
A checkRestrictedGrantType() 0 5 1
1
<?php
2
3
namespace OAuth\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use OAuth2\Storage\ClientCredentialsInterface;
7
8
class ClientRepository extends EntityRepository implements ClientCredentialsInterface
9
{
10
    /**
11
     * @param string $clientId
12
     * @param string|null $clientSecret
13
     * @return bool
14
     */
15
    public function checkClientCredentials($clientId, $clientSecret = null)
16
    {
17
        $client = $this->findOneBy(['clientIdentifier' => $clientId]);
18
        if ($client) {
19
            return $client->verifyClientSecret($clientSecret);
20
        }
21
        return false;
22
    }
23
24
    /**
25
     * @param $clientId
26
     * @return bool
27
     */
28
    public function isPublicClient($clientId)
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @param $clientId
35
     * @return null|array
36
     */
37
    public function getClientDetails($clientId)
38
    {
39
        $client = $this->findOneBy(['clientIdentifier' => $clientId]);
40
        if ($client) {
41
            $client = $client->toArray();
42
        }
43
        return $client;
44
    }
45
46
    /**
47
     * @param $client_id
48
     * @return null
49
     */
50
    public function getClientScope($client_id)
51
    {
52
        return null;
53
    }
54
55
    /**
56
     * @param $clientId
57
     * @param $grantType
58
     * @return bool
59
     */
60
    public function checkRestrictedGrantType($clientId, $grantType)
61
    {
62
        // we do not support different grant types per client in this example
63
        return true;
64
    }
65
66
67
}