IdStore   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 2
b 0
f 0
dl 0
loc 29
rs 10
ccs 13
cts 13
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A injectCacheManager() 0 3 1
A set() 0 9 1
1
<?php
2
3
namespace DMK\MKSamlAuth\Store;
4
5
use LightSaml\Store\Id\IdStoreInterface;
6
use TYPO3\CMS\Core\Cache\CacheManager;
7
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
8
use TYPO3\CMS\Core\SingletonInterface;
9
10
class IdStore implements IdStoreInterface, SingletonInterface
11
{
12
    const CACHE_KEY = 'mksamlauth_idstore';
13
14
    /**
15
     * @var FrontendInterface
16
     */
17
    private $cache;
18
19 2
    public function injectCacheManager(CacheManager $cacheManager)
20
    {
21 2
        $this->cache = $cacheManager->getCache(self::CACHE_KEY);
22 2
    }
23
24 1
    public function set($entityId, $id, \DateTime $expiryTime)
25
    {
26 1
        $now = new \DateTime();
27
28 1
        $this->cache->set(
29 1
            md5($entityId.$id),
30 1
            md5($entityId.$id),
31 1
            [],
32 1
            $expiryTime->getTimestamp() - $now->getTimestamp()
33
        );
34 1
    }
35
36 1
    public function has($entityId, $id)
37
    {
38 1
        return $this->cache->has(md5($entityId.$id));
39
    }
40
}
41