Client::get()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 3
nop 4
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