StashCacheAdapter::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Http Adapter package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\HttpAdapter\Event\Cache\Adapter;
13
14
use Stash\Pool;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class StashCacheAdapter implements CacheAdapterInterface
20
{
21
    /**
22
     * @var Pool
23
     */
24
    private $pool;
25
26
    /**
27
     * @param Pool $pool
28
     */
29 45
    public function __construct(Pool $pool)
30
    {
31 45
        $this->pool = $pool;
32 45
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 9
    public function has($id)
38
    {
39 9
        return !$this->pool->getItem($id)->isMiss();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 9
    public function get($id)
46
    {
47 9
        return $this->pool->getItem($id)->get();
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 9
    public function set($id, $data, $lifeTime = 0)
54
    {
55 9
        $result = $this->pool->getItem($id)->set($data, $lifeTime);
0 ignored issues
show
Unused Code introduced by GeLo
The call to ItemInterface::set() has too many arguments starting with $lifeTime.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
56 9
        $this->pool->flush();
0 ignored issues
show
Bug introduced by GeLo
The method flush() does not seem to exist on object<Stash\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58 9
        return $result;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 9
    public function remove($id)
65
    {
66 9
        $result = $this->pool->getItem($id)->clear();
67 9
        $this->pool->flush();
0 ignored issues
show
Bug introduced by GeLo
The method flush() does not seem to exist on object<Stash\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
69 9
        return $result;
70
    }
71
}
72