Completed
Pull Request — master (#129)
by Eric
257:01 queued 192:06
created

src/Event/Cache/Adapter/StashCacheAdapter.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 * Stash cache adapter.
18
 *
19
 * @author GeLo <[email protected]>
20
 */
21
class StashCacheAdapter implements CacheAdapterInterface
22
{
23
    /** @var \Stash\Pool */
24
    private $pool;
25
26
    /**
27
     * Creates a stash cache.
28
     *
29
     * @param \Stash\Pool $pool The stash pool.
30
     */
31 95
    public function __construct(Pool $pool)
32
    {
33 95
        $this->pool = $pool;
34 95
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 19
    public function has($id)
40
    {
41 19
        return !$this->pool->getItem($id)->isMiss();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 19
    public function get($id)
48
    {
49 19
        return $this->pool->getItem($id)->get();
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 19
    public function set($id, $data, $lifeTime = 0)
56
    {
57 19
        $result = $this->pool->getItem($id)->set($data, $lifeTime);
58 19
        $this->pool->flush();
0 ignored issues
show
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...
59
60 19
        return $result;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 19
    public function remove($id)
67
    {
68 19
        $result = $this->pool->getItem($id)->clear();
69 19
        $this->pool->flush();
0 ignored issues
show
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...
70
71 19
        return $result;
72
    }
73
}
74