Completed
Push — in_memory ( c3a551 )
by Jamal
09:35
created

TokenLoader   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 52
rs 10
c 0
b 0
f 0
ccs 0
cts 24
cp 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 4
A retrieveByHash() 0 4 1
A retrieveExpired() 0 4 1
1
<?php
2
3
namespace Majora\Component\OAuth\Loader\InMemory;
4
5
use Majora\Component\OAuth\Loader\TokenLoaderInterface;
6
use Majora\Framework\Loader\Bridge\InMemory\InMemoryLoaderTrait;
7
use Majora\Framework\Date\Clock;
8
use Majora\Framework\Model\EntityCollection;
9
use Majora\Framework\Normalizer\MajoraNormalizer;
10
11
/**
12
 * ORM token loading implementation.
13
 */
14
class TokenLoader implements TokenLoaderInterface
15
{
16
    use InMemoryLoaderTrait;
17
18
    /**
19
     * @var Clock
20
     */
21
    protected $clock;
22
23
    /**
24
     * Construct.
25
     *
26
     * @param string           $collectionClass
27
     * @param MajoraNormalizer $normalizer
28
     * @param Clock           $clock
29
     */
30
    public function __construct($collectionClass, MajoraNormalizer $normalizer, Clock $clock)
31
    {
32
        if (empty($collectionClass) || !class_exists($collectionClass)) {
33
            throw new \InvalidArgumentException(sprintf(
34
                'You must provide a valid EntityCollection class name, "%s" given.',
35
                $collectionClass
36
            ));
37
        }
38
        $this->entityCollection = new $collectionClass();
39
        if (!$this->entityCollection instanceof EntityCollection) {
40
            throw new \InvalidArgumentException(sprintf(
41
                'Provided class name is not an Majora\Framework\Model\EntityCollection, "%s" given.',
42
                $collectionClass
43
            ));
44
        }
45
46
        $this->normalizer = $normalizer;
47
        $this->clock = $clock;
48
    }
49
50
    /**
51
     * @see TokenLoaderInterface::retrieveByHash()
52
     */
53
    public function retrieveByHash($hash)
54
    {
55
56
    }
57
58
    /**
59
     * @see TokenLoaderInterface::retrieveExpired()
60
     */
61
    public function retrieveExpired(\DateTime $datetime = null)
62
    {
63
64
    }
65
}
66