for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Storeman\VaultLayout;
use Storeman\Index;
use Storeman\IndexObject;
class LazyLoadedIndex extends Index
{
protected $pathMap = null;
/**
* @var callable
*/
protected $indexLoader;
public function __construct(callable $indexLoader)
$this->indexLoader = $indexLoader;
}
* {@inheritdoc}
public function addObject(IndexObject $indexObject): Index
$this->loadIndex();
return parent::addObject($indexObject);
public function getObjectByPath(string $path): ?IndexObject
return parent::getObjectByPath($path);
public function getObjectByBlobId(string $blobId): ?IndexObject
return parent::getObjectByBlobId($blobId);
public function count(): int
return parent::count();
public function getIterator(): \Traversable
return parent::getIterator();
* Lazy-loads the actual index from the injected loader.
protected function loadIndex()
if ($this->pathMap === null)
$index = call_user_func($this->indexLoader);
if (!($index instanceof Index))
throw new \LogicException();
$this->pathMap = $index->pathMap;