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

ClientRepository::save()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 2
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 6
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
}