This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Part of the Joomla Framework Cache Package |
||
4 | * |
||
5 | * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. |
||
6 | * @license GNU General Public License version 2 or later; see LICENSE |
||
7 | */ |
||
8 | |||
9 | namespace Joomla\Cache\Item; |
||
10 | |||
11 | use Joomla\Cache\Exception\InvalidArgumentException; |
||
12 | |||
13 | /** |
||
14 | * Cache item instance for the Joomla Framework. |
||
15 | * |
||
16 | * @since 1.0 |
||
17 | * @deprecated The joomla/cache package is deprecated |
||
18 | */ |
||
19 | class Item extends AbstractItem |
||
0 ignored issues
–
show
|
|||
20 | { |
||
21 | /** |
||
22 | * The time the object expires at |
||
23 | * |
||
24 | * @var \DateTimeInterface |
||
25 | * @since __DEPLOY_VERSION__ |
||
26 | */ |
||
27 | private $expiration; |
||
28 | |||
29 | /** |
||
30 | * The key for the cache item. |
||
31 | * |
||
32 | * @var string |
||
33 | * @since 1.0 |
||
34 | */ |
||
35 | private $key; |
||
36 | |||
37 | /** |
||
38 | * The value of the cache item. |
||
39 | * |
||
40 | * @var mixed |
||
41 | * @since 1.0 |
||
42 | */ |
||
43 | private $value; |
||
44 | |||
45 | /** |
||
46 | * Whether the cache item has been hit. |
||
47 | * |
||
48 | * @var boolean |
||
49 | * @since 1.0 |
||
50 | */ |
||
51 | private $hit = false; |
||
52 | |||
53 | /** |
||
54 | * Class constructor. |
||
55 | * |
||
56 | * @param string $key The key for the cache item. |
||
57 | * @param \DateInterval|\DateTimeInterface|integer|null $ttl The expiry time for the cache item in seconds or as a datetime object |
||
58 | * |
||
59 | * @since 1.0 |
||
60 | */ |
||
61 | 54 | public function __construct($key, $ttl = null) |
|
62 | { |
||
63 | 54 | $this->key = $key; |
|
64 | |||
65 | 54 | if (is_int($ttl) || ($ttl instanceof \DateInterval)) |
|
66 | { |
||
67 | $this->expiresAfter($ttl); |
||
68 | } |
||
69 | 54 | elseif ($ttl instanceof \DateTimeInterface) |
|
70 | { |
||
71 | $this->expiresAt($ttl); |
||
72 | } |
||
73 | else |
||
74 | { |
||
75 | 54 | $this->expiresAfter(900); |
|
76 | } |
||
77 | 54 | } |
|
78 | |||
79 | /** |
||
80 | * Confirms if the cache item exists in the cache. |
||
81 | * |
||
82 | * Note: This method MAY avoid retrieving the cached value for performance |
||
83 | * reasons, which could result in a race condition between exists() and get(). |
||
84 | * To avoid that potential race condition use isHit() instead. |
||
85 | * |
||
86 | * @return boolean |
||
87 | * |
||
88 | * @since __DEPLOY_VERSION__ |
||
89 | */ |
||
90 | public function exists() |
||
91 | { |
||
92 | return $this->isHit(); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Returns the key for the current cache item. |
||
97 | * |
||
98 | * @return string The key string for this cache item. |
||
99 | * |
||
100 | * @since 1.0 |
||
101 | */ |
||
102 | 39 | public function getKey() |
|
103 | { |
||
104 | 39 | return $this->key; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * Retrieves the value of the item from the cache associated with this object's key. |
||
109 | * |
||
110 | * @return mixed The value corresponding to this cache item's key, or null if not found. |
||
111 | * |
||
112 | * @since 1.0 |
||
113 | */ |
||
114 | 41 | public function get() |
|
115 | { |
||
116 | 41 | return $this->value; |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * Sets the value represented by this cache item. |
||
121 | * |
||
122 | * If the value is set, we are assuming that there was a valid hit on the cache for the given key. |
||
123 | * |
||
124 | * @param mixed $value The serializable value to be stored. |
||
125 | * |
||
126 | * @return $this |
||
127 | * |
||
128 | * @since 1.0 |
||
129 | */ |
||
130 | 49 | public function set($value) |
|
131 | { |
||
132 | 49 | $this->value = $value; |
|
133 | 49 | $this->hit = true; |
|
134 | |||
135 | 49 | return $this; |
|
136 | } |
||
137 | |||
138 | /** |
||
139 | * Confirms if the cache item lookup resulted in a cache hit. |
||
140 | * |
||
141 | * @return boolean True if the request resulted in a cache hit. False otherwise. |
||
142 | * |
||
143 | * @since 1.0 |
||
144 | */ |
||
145 | 33 | public function isHit() |
|
146 | { |
||
147 | 33 | return $this->hit; |
|
148 | } |
||
149 | |||
150 | /** |
||
151 | * Sets the expiration time for this cache item. |
||
152 | * |
||
153 | * @param \DateTimeInterface|null $expiration The point in time after which the item MUST be considered expired. |
||
154 | * If null is passed explicitly, a default value MAY be used. If none is |
||
155 | * set, the value should be stored permanently or for as long as the |
||
156 | * implementation allows. |
||
157 | * |
||
158 | * @return $this |
||
159 | * |
||
160 | * @since __DEPLOY_VERSION__ |
||
161 | * @throws InvalidArgumentException |
||
162 | */ |
||
163 | public function expiresAt($expiration) |
||
164 | { |
||
165 | if ($expiration !== null && !($expiration instanceof \DateTimeInterface)) |
||
166 | { |
||
167 | throw new InvalidArgumentException( |
||
0 ignored issues
–
show
The class
Joomla\Cache\Exception\InvalidArgumentException has been deprecated with message: The joomla/cache package is deprecated
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. ![]() |
|||
168 | sprintf( |
||
169 | 'Argument 1 passed to %s::expiresAt() must be an instance of DateTimeInterface; %s given', |
||
170 | get_class($this), |
||
171 | is_object($expiration) ? get_class($expiration) : gettype($expiration) |
||
172 | ) |
||
173 | ); |
||
174 | } |
||
175 | |||
176 | $this->expiration = $expiration; |
||
177 | |||
178 | return $this; |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Sets the expiration time for this cache item. |
||
183 | * |
||
184 | * @param int|\DateInterval|null $time The period of time from the present after which the item MUST be considered |
||
185 | * expired. An integer parameter is understood to be the time in seconds until |
||
186 | * expiration. |
||
187 | * |
||
188 | * @return $this |
||
189 | * |
||
190 | * @since __DEPLOY_VERSION__ |
||
191 | */ |
||
192 | 54 | public function expiresAfter($time) |
|
193 | { |
||
194 | 54 | if (is_integer($time)) |
|
195 | { |
||
196 | 54 | $this->expiration = new \DateTime('now +' . $time . ' seconds'); |
|
197 | } |
||
198 | 31 | elseif ($time instanceof \DateInterval) |
|
199 | { |
||
200 | $this->expiration = new \DateTime('now'); |
||
201 | $this->expiration->add($time); |
||
202 | } |
||
203 | else |
||
204 | { |
||
205 | 31 | $this->expiration = new \DateTime('now + 900 seconds'); |
|
206 | } |
||
207 | |||
208 | 54 | return $this; |
|
209 | } |
||
210 | |||
211 | /** |
||
212 | * Returns the expiration time of a not-yet-expired cache item. |
||
213 | * |
||
214 | * If this cache item is a Cache Miss, this method MAY return the time at which the item expired or the current time if that is not available. |
||
215 | * |
||
216 | * @return \DateTimeInterface The timestamp at which this cache item will expire. |
||
217 | * |
||
218 | * @since __DEPLOY_VERSION__ |
||
219 | */ |
||
220 | 21 | public function getExpiration(): \DateTimeInterface |
|
221 | { |
||
222 | 21 | return $this->expiration; |
|
223 | } |
||
224 | } |
||
225 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.