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;
/**
* Container entry that uses a callable to determine the value for the entry.
*
* @author Riikka Kalliomäki <[email protected]>
* @copyright Copyright (c) 2018 Riikka Kalliomäki
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class CallableEntry implements EntryInterface
{
/** @var callable The callable used to determine the value for the entry */
private $callable;
* CallableEntry constructor.
* @param callable $callable The callable used to determine the value for the entry
public function __construct(callable $callable)
$this->callable = $callable;
}
/** {@inheritdoc} */
public static function createFromCacheParameters(array $parameters): EntryInterface
return new static($parameters[0]);
public function getCacheParameters(): array
return [$this->callable];
public function isFactory(): bool
return false;
public function getValue(ContainerInterface $container)
return ($this->callable)($container);