key; } /** * {@inheritdoc} */ public function get() { return $this->isHit() ? $this->value : null; } /** * {@inheritdoc} */ public function set($value = null) { $this->value = $value; return $this; } /** * {@inheritdoc} */ public function isHit() { return $this->hit; } /** * {@inheritdoc} */ public function expiresAt($expiration) { if (is_null($expiration)) { $this->expiration = new \DateTime('now +1 year'); } else { assert('$expiration instanceof \DateTimeInterface'); $this->expiration = $expiration; } return $this; } /** * {@inheritdoc} */ public function expiresAfter($time) { if (is_null($time)) { $this->expiration = new \DateTime('now +1 year'); } elseif (is_numeric($time)) { $this->expiration = new \DateTime('now +' . $time . ' seconds'); } else { assert('$time instanceof DateInterval'); $expiration = new \DateTime(); $expiration->add($time); $this->expiration = $expiration; } return $this; } }