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

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

            $this->createDirectory($directory);
        }
    }
protected function ensureDirectoryExists ( $ directory , $ create = false ) { if ( ! is_dir ( $ directory ) ) { if ( ! $ create ) { throw new \ RuntimeException ( sprintf ( 'The directory "%s" does not exist.' , $ directory ) ) ; } $ this -> createDirectory ( $ directory ) ; } }
Ensures the specified directory exists, creates it if it does not.

@param string $directory Path of the directory to test
@param bool   $create    Whether to create the directory if it does
not exist

@throws \InvalidArgumentException if the directory already exists
@throws \RuntimeException if the directory does not exists and could not
be created
Ensures the specified directory exists creates it if it does not .