protected function ensureDirectoryExists($directory, $create = false) { if (!$this->isDir($directory)) { if (!$create) { throw new \RuntimeException(sprintf('The directory \'%s\' does not exist.', $directory)); } $this->createDirectory($directory); } }