trait GetCache
{
public function __call(string $name, $arguments) {
$action = substr($name, 0, 5);
$property = strtolower(substr($name, 5));
switch ($action) {
case 'cache':
if (!isset($this->$property)) {
$this->$property = $this->$property(...$arguments);
}
return $this->$property;
break;
default :
return false; // Exception
break;
}
}