for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Jaxon\App\Stash;
use function is_callable;
class Stash
{
/**
* @var array
*/
private array $values = [];
* @param string $key
* @param mixed $value
*
* @return void
public function set(string $key, mixed $value): void
$this->values[$key] = $value;
}
* @param mixed $default
* @return mixed
public function get(string $key, mixed $default = null): mixed
$value = $this->values[$key] ?? $default;
if(is_callable($value))
$value = $value();
// Save the value returned by the callback in the stash.
return $value;