Test Failed
Push — master ( a6b51e...5fffdb )
by Gabriel
08:05
created

Clients   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0
wmc 6
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClientEntity() 0 18 5
A generateTable() 0 4 1
1
<?php
2
3
namespace ByTIC\Hello\Models\Clients;
4
5
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
6
use Nip\Records\Collections\Collection;
7
use Nip\Utility\Traits\SingletonTrait;
8
9
/**
10
 * Class Tokens
11
 * @package ByTIC\Hello\Models\Clients
12
 *
13
 * @method Client getNew()
14
 * @method Client findOneByIdentifier(string $clientIdentifier)
15
 * @method Client findOne(string $clientIdentifier)
16
 *
17
 * @method Client[]|Collection findByRedirect(string $uri)
18
 */
19
class Clients extends \Nip\Records\RecordManager implements ClientRepositoryInterface
20
{
21
    use SingletonTrait;
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getClientEntity(
27
        $clientIdentifier,
28
        $grantType = null,
29
        $clientSecret = null,
30
        $mustValidateSecret = true
31
    ) {
32
        // First, we will verify that the client exists
33
        $client = $this->findOneByIdentifier($clientIdentifier);
34
35
        if (!$client || !$client->handlesGrant($grantType)) {
36
            return;
37
        }
38
39
        if ($mustValidateSecret && !$client->validateSecret($clientSecret)) {
40
            return;
41
        }
42
        return $client;
43
    }
44
45
    /** @noinspection PhpMissingParentCallCommonInspection
46
     * @inheritDoc
47
     */
48
    protected function generateTable()
49
    {
50
        return 'oauth_clients';
51
    }
52
}
53