for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Prelude;
const memoize = __NAMESPACE__.'\memoize';
use Closure;
function memoize(callable $callback): Closure
{
return function (...$args) use ($callback) {
static $cache = [];
$key = md5(serialize($args));
if (!isset($cache[$key])) {
$cache[$key] = $callback(...$args);
}
return $cache[$key];
};