1 | <?php namespace Comodojo\Cache; |
||
26 | class Item implements CacheItemInterface { |
||
27 | |||
28 | protected $key; |
||
29 | |||
30 | protected $data; |
||
31 | |||
32 | protected $hit = false; |
||
33 | |||
34 | protected $expiration = 0; |
||
35 | |||
36 | 196 | public function __construct($key, $hit = false) { |
|
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 129 | public function getKey() { |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 154 | public function get() { |
|
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | 164 | public function isHit() { |
|
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | 172 | public function set($value) { |
|
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | 57 | public function expiresAt($expiration = null) { |
|
91 | |||
92 | 57 | if ( is_null($expiration) ) { |
|
93 | $this->expiration = 0; |
||
94 | } |
||
95 | |||
96 | 57 | if ( $expiration instanceof DateTimeInterface ) { |
|
97 | 57 | $this->expiration = $expiration; |
|
98 | 57 | } |
|
99 | |||
100 | 57 | return $this; |
|
101 | |||
102 | } |
||
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | 25 | public function expiresAfter($time) { |
|
108 | |||
109 | 25 | if ( is_null($time) ) { |
|
110 | $this->expiration = 0; |
||
111 | } |
||
112 | |||
113 | 25 | if ( is_numeric($time) ) { |
|
114 | 25 | $this->expiration = new DateTime('now +'.$time.' seconds'); |
|
115 | 25 | } |
|
116 | |||
117 | 25 | if ( $time instanceof DateInterval ) { |
|
118 | $expiration = new DateTime('now'); |
||
119 | $expiration->add($time); |
||
120 | $this->expiration = $expiration; |
||
121 | } |
||
122 | |||
123 | 25 | return $this; |
|
124 | |||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Returns the raw value, regardless of hit status. |
||
129 | * |
||
130 | * Although not part of the CacheItemInterface, this method is used by |
||
131 | * the pool for extracting information for saving. |
||
132 | * |
||
133 | * @return mixed |
||
134 | * |
||
135 | * @internal |
||
136 | */ |
||
137 | 122 | public function getRaw() { |
|
142 | |||
143 | /** |
||
144 | * Get currently (calculated) ttl of cache item |
||
145 | * |
||
146 | * This method is not part of the CacheItemInterface. |
||
147 | * |
||
148 | * @return int |
||
149 | * |
||
150 | * @internal |
||
151 | */ |
||
152 | 170 | public function getTtl() { |
|
165 | |||
166 | /** |
||
167 | * Get expiration time (absolute) |
||
168 | * |
||
169 | * This method is not part of the CacheItemInterface. |
||
170 | * |
||
171 | * @return int |
||
172 | * |
||
173 | * @internal |
||
174 | */ |
||
175 | 1 | public function getExpiration() { |
|
180 | |||
181 | 1 | public function __toString() { |
|
186 | |||
187 | } |
||
188 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.