JamesMoss\Flywheel\Repository::__construct PHP Method

__construct() public method

Constructor
public __construct ( string $name, Config $config )
$name string The name of the repository. Must match /[A-Za-z0-9_-]{1,63}+/
$config Config The config to use for this repo
    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));
            }
        }
    }