for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Simply\Container\Entry;
use Psr\Container\ContainerInterface;
/**
* A standard container entry that may be any value or a closure used to determine that value.
*
* @author Riikka Kalliomäki <[email protected]>
* @copyright Copyright (c) 2018 Riikka Kalliomäki
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class MixedEntry implements EntryInterface
{
/** @var mixed The value for the entry */
private $value;
* MixedType constructor.
* @param mixed $value The value for the entry
public function __construct($value)
$this->value = $value;
}
/** {@inheritdoc} */
public static function createFromCacheParameters(array $parameters): EntryInterface
return new static($parameters[0]);
public function getCacheParameters(): array
return [$this->value];
public function isFactory(): bool
return false;
public function getValue(ContainerInterface $container)
if ($this->value instanceof \Closure) {
return ($this->value)($container);
return $this->value;