|
@@ 154-161 (lines=8) @@
|
| 151 |
|
$this->expiry = CacheItem::DEFAULT_TIMEOUT > 0 ? time() + CacheItem::DEFAULT_TIMEOUT : null; |
| 152 |
|
} elseif ($expiration instanceof \DateTimeInterface) { |
| 153 |
|
$this->expiry = (int) $expiration->format('U'); |
| 154 |
|
} else { |
| 155 |
|
throw new \InvalidArgumentException( |
| 156 |
|
sprintf( |
| 157 |
|
'Expiration date must implement DateTimeInterface or be null, "%s" given', |
| 158 |
|
is_object($expiration) ? get_class($expiration) : gettype($expiration) |
| 159 |
|
) |
| 160 |
|
); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
return $this; |
| 164 |
|
} |
|
@@ 184-186 (lines=3) @@
|
| 181 |
|
$this->expiry = (int) \DateTime::createFromFormat('U', time())->add($time)->format('U'); |
| 182 |
|
} elseif (\is_int($time)) { |
| 183 |
|
$this->expiry = $time + time(); |
| 184 |
|
} else { |
| 185 |
|
throw new \InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($time) ? \get_class($time) : \gettype($time))); |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
return $this; |
| 189 |
|
} |