for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bdf\Prime\Cache;
/**
* Class CacheKey
*/
final class CacheKey
{
* @var string|callable
private $namespace;
private $key;
* @var integer
private $lifetime = 0;
* CacheKey constructor.
* @param callable|string $namespace
* @param callable|string $key
* @param int $lifetime
public function __construct($namespace = null, $key = null, int $lifetime = 0)
$this->namespace = $namespace;
$this->key = $key;
$this->lifetime = $lifetime;
}
* @return string
public function namespace(): string
return is_string($this->namespace) ? $this->namespace : ($this->namespace)();
* @param string|callable $namespace
*
* @return $this
public function setNamespace($namespace): CacheKey
return $this;
public function key(): ?string
return is_string($this->key) ? $this->key : ($this->key)();
* @param string|callable $key
public function setKey($key): CacheKey
* @return int
public function lifetime(): int
return $this->lifetime;
public function setLifetime(int $lifetime): CacheKey
public function valid(): bool
return !empty($this->key());