Passed
Pull Request — master (#39)
by Daniel
03:37
created

CacheSymfonyFacade   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A get() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Jellyfish\CacheSymfony;
4
5
use Jellyfish\Cache\CacheFacadeInterface;
6
7
class CacheSymfonyFacade implements CacheFacadeInterface
8
{
9
    /**
10
     * @var \Jellyfish\CacheSymfony\CacheSymfonyFactory
11
     */
12
    protected $factory;
13
14
    /**
15
     * @param \Jellyfish\CacheSymfony\CacheSymfonyFactory $factory
16
     */
17
    public function __construct(CacheSymfonyFactory $factory)
18
    {
19
        $this->factory = $factory;
20
    }
21
22
    /**
23
     * @param string $key
24
     *
25
     * @return string|null
26
     */
27
    public function get(string $key): ?string
28
    {
29
        return $this->factory->getCache()->get($key);
30
    }
31
32
    /**
33
     * @param string $key
34
     * @param string $value
35
     * @param int|null $lifeTime
36
     *
37
     * @return \Jellyfish\Cache\CacheFacadeInterface
38
     *
39
     * @throws \Jellyfish\Cache\Exception\InvalidLifeTimeException
40
     */
41
    public function set(string $key, string $value, ?int $lifeTime = null): CacheFacadeInterface
42
    {
43
        $this->factory->getCache()->set($key, $value, $lifeTime);
44
45
        return $this;
46
    }
47
}
48