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

TokenLoader::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.2
c 0
b 0
f 0
ccs 0
cts 18
cp 0
cc 4
eloc 12
nc 3
nop 3
crap 20
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