InMemoryClientStorage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 4 1
A delete() 0 9 2
A findById() 0 9 2
1
<?php
2
3
namespace Bgy\OAuth2\Storage\InMemory;
4
5
use Bgy\OAuth2\Storage\ClientNotFound;
6
use Bgy\OAuth2\Storage\ClientStorage;
7
use Bgy\OAuth2\Client as ClientModel;
8
9
/**
10
 * @author Boris Guéry <[email protected]>
11
 */
12
class InMemoryClientStorage implements ClientStorage
13
{
14
    private $clients = [];
15
16
    public function save(ClientModel $client)
17
    {
18
        $this->clients[$client->getId()] = $client;
19
    }
20
21
    public function delete(ClientModel $client)
22
    {
23
        if (!isset($this->clients[$client->getId()])) {
24
25
            throw new ClientNotFound($client->getId());
26
        }
27
28
        unset($this->clients[$client->getId()]);
29
    }
30
31
    public function findById($clientId)
32
    {
33
        if (!isset($this->clients[$clientId])) {
34
35
            throw new ClientNotFound($clientId);
36
        }
37
38
        return $this->clients[$clientId];
39
    }
40
}
41