public function __construct($path, $dirPermissions = 0700)
{
if (!file_exists($path)) {
# directory doesn't exist, try to create one
if (!mkdir($path, $dirPermissions, true)) {
throw new Exception('Directory "' . $path . '" does not exist.');
}
# create default .gitignore, to ignore stored json files
file_put_contents($path . '/.gitignore', "*.json\n");
}
if (!is_writable($path)) {
throw new Exception('Path "' . $path . '" is not writable.');
}
$this->path = $path;
}