public function __construct($name, Config $config)
{
// Setup class properties
$this->name = $name;
$this->path = $config->getPath() . DIRECTORY_SEPARATOR . $name;
$this->formatter = $config->getOption('formatter');
$this->queryClass = $config->getOption('query_class');
$this->documentClass = $config->getOption('document_class');
// Ensure the repo name is valid
$this->validateName($this->name);
// Ensure directory exists and we can write there
if (!is_dir($this->path)) {
if (!@mkdir($this->path, 0777, true)) {
throw new \RuntimeException(sprintf('`%s` doesn\'t exist and can\'t be created.', $this->path));
}
} else {
if (!is_writable($this->path)) {
throw new \RuntimeException(sprintf('`%s` is not writable.', $this->path));
}
}
}