Skip to content

Commit f7058aa

Browse files
committed
Fix Rector complaints
1 parent 70b8cab commit f7058aa

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

system/Psr/Cache/Item.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function set($value): self
160160
/**
161161
* Sets the expiration time for this cache item.
162162
*
163-
* @param \DateTimeInterface|null $expiration
163+
* @param DateTimeInterface|null $expiration
164164
* The point in time after which the item MUST be considered expired.
165165
* If null is passed explicitly, a default value MAY be used. If none is set,
166166
* the value should be stored permanently or for as long as the
@@ -190,7 +190,7 @@ public function expiresAt($expiration): self
190190
/**
191191
* Sets the expiration time for this cache item.
192192
*
193-
* @param integer|\DateInterval|null $time
193+
* @param integer|DateInterval|null $time
194194
* The period of time from the present after which the item MUST be considered
195195
* expired. An integer parameter is understood to be the time in seconds until
196196
* expiration. If null is passed explicitly, a default value MAY be used.

system/Psr/Cache/Pool.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,7 @@ public function save(CacheItemInterface $item)
273273
}
274274

275275
// Deteremine TTL
276-
if ($expiration = $item->getExpiration())
277-
{
278-
$ttl = Time::now()->difference($expiration)->getSeconds();
279-
}
280-
// Set it never to expire
281-
else
282-
{
283-
$ttl = 0;
284-
}
276+
$ttl = ($expiration = $item->getExpiration()) ? Time::now()->difference($expiration)->getSeconds() : 0;
285277

286278
return $this->adapter->save($item->getKey(), $item->get(), $ttl);
287279
}

system/Psr/Cache/SimpleCache.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function get($key, $default = null)
4949
/**
5050
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
5151
*
52-
* @param string $key The key of the item to store.
53-
* @param mixed $value The value of the item to store. Must be serializable.
54-
* @param null|integer|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
52+
* @param string $key The key of the item to store.
53+
* @param mixed $value The value of the item to store. Must be serializable.
54+
* @param null|integer|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
5555
* the driver supports TTL then the library may set a default value
5656
* for it or let the driver take care of that.
5757
*
@@ -154,8 +154,8 @@ public function getMultiple($keys, $default = null)
154154
/**
155155
* Persists a set of key => value pairs in the cache, with an optional TTL.
156156
*
157-
* @param iterable $values A list of key => value pairs for a multiple-set operation.
158-
* @param null|integer|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
157+
* @param iterable $values A list of key => value pairs for a multiple-set operation.
158+
* @param null|integer|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
159159
* the driver supports TTL then the library may set a default value
160160
* for it or let the driver take care of that.
161161
*
@@ -239,12 +239,7 @@ public function has($key)
239239

240240
$meta = $this->adapter->getMetaData($key);
241241

242-
// If the adapter does not return an array or if the item is expired then it is a miss
243-
if (! is_array($meta) || (is_int($meta['expire']) && $meta['expire'] < time()))
244-
{
245-
return false;
246-
}
247-
248-
return true;
242+
// The adapter must return an array that is not expired
243+
return is_array($meta) && is_int($meta['expire']) && $meta['expire'] > time();
249244
}
250245
}

0 commit comments

Comments
 (0)