NoCacheItem::isHit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Perry\Cache\NoCache;
4
5
use Psr\Cache\ItemInterface;
6
7
/**
8
 * Class NoCacheItem, a cache that doesn't.
9
 *
10
 * @package Perry\Cache\NoCache
11
 */
12
class NoCacheItem implements ItemInterface
13
{
14
15
    /**
16
     * @var string
17
     */
18
    private $key;
19
20
    /**
21
     * @param string $key
22
     */
23
    public function __construct($key)
24
    {
25
        $this->key = $key;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getKey()
32
    {
33
        return $this->key;
34
    }
35
36
    /**
37
     * always null since we don't cache
38
     * @return \Serializable|mixed
39
     */
40
    public function get()
41
    {
42
        return null;
43
    }
44
45
    /**
46
     * as if..
47
     *
48
     * @param \Serializable $value
49
     * @param int $ttl
50
     * @returns boolean
51
     */
52
    public function set($value = null, $ttl = null)
53
    {
54
        return true;
55
    }
56
57
    /**
58
     * we never hit the cache since we dont cache
59
     * @return bool
60
     */
61
    public function isHit()
62
    {
63
        return false;
64
    }
65
66
    /**
67
     * Removes the current key from the cache.
68
     *
69
     * @return \Psr\Cache\ItemInterface
70
     *   The current item.
71
     */
72
    public function delete()
73
    {
74
        return $this;
75
    }
76
77
    /**
78
     * nope doesnt exist. ever
79
     * @return bool
80
     */
81
    public function exists()
82
    {
83
        return false;
84
    }
85
}
86