Skip to content

Instantly share code, notes, and snippets.



Last active Aug 17, 2020
What would you like to do?
trait Memoize
* @var array [method][parameters]
private $memoizedResults = [];
protected function memoizedCall($methodName, $args)
$serializedArgs = \serialize($args);
if (! isset($this->memoizedResults[$methodName][$serializedArgs])) {
$this->memoizedResults[$methodName][$serializedArgs] =
return $this->memoizedResults[$methodName][$serializedArgs];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.