Client   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 12 4
A getBySession() 0 4 1
1
<?php
2
3
namespace Eole\Sandstone\OAuth2\Storage;
4
5
use League\OAuth2\Server\Entity\SessionEntity;
6
use League\OAuth2\Server\Entity\ClientEntity;
7
use League\OAuth2\Server\Storage\ClientInterface;
8
use League\OAuth2\Server\Storage\AbstractStorage;
9
10
class Client extends AbstractStorage implements ClientInterface
11
{
12
    /**
13
     * @var array[]
14
     */
15
    private $clients;
16
17
    /**
18
     * @param array[] $clients
19
     */
20
    public function __construct(array $clients)
21
    {
22
        $this->clients = $clients;
23
    }
24
25
    /**
26
     * {@InheritDoc}
27
     */
28
    public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
29
    {
30
        foreach ($this->clients as $client) {
31
            if (($client['id'] === $clientId) && ($client['secret'] === $clientSecret)) {
32
                $clientEntity = new ClientEntity($this->server);
33
34
                return $clientEntity->hydrate($client);
35
            }
36
        }
37
38
        return null;
39
    }
40
41
    /**
42
     * {@InheritDoc}
43
     */
44
    public function getBySession(SessionEntity $session)
45
    {
46
        throw new \Eole\Sandstone\OAuth2\Exception\NotImplementedException();
47
    }
48
}
49