HippoPHP\Hippo\LazyFactory::get PHP Method

get() public method

public get ( mixed $cacheKey, callable $factory ) : mixed
$cacheKey mixed
$factory callable
return mixed
    public function get($cacheKey, callable $factory)
    {
        if (!isset($this->cache[$cacheKey])) {
            $this->cache[$cacheKey] = $factory();
        }
        return $this->cache[$cacheKey];
    }

Usage Example

Beispiel #1
0
 /**
  * @return mixed
  */
 public function getSyntaxTree()
 {
     return $this->lazyFactory->get(self::CONTEXT_AST, function () {
         $parser = new Parser(new Emulative());
         $stmts = $parser->parse($this->file->getSource());
         return $stmts;
     });
 }