Passed
Push — master ( 3991b6...e9cdac )
by Gabriel
02:46
created

Clients::validateClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
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)) {
0 ignored issues
show
introduced by
$client is of type ByTIC\Hello\Models\Clients\Client, thus it always evaluated to true.
Loading history...
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
    /**
54
     * @inheritDoc
55
     * @TODO add some validation logic
56
     */
57
    public function validateClient($clientIdentifier, $clientSecret, $grantType)
58
    {
59
        return true;
60
    }
61
}
62