public function createDirectory($directory)
    {
        // create parent directory if needed
        $parent = dirname($directory);
        if (!$this->directoryExists($parent)) {
            $this->createDirectory($parent);
        }

        if (ftp_mkdir($this->connection(), $directory) === false) {
            throw new \RuntimeException(sprintf(
                'Could not create directory \'%s\'.',
                $directory
            ));
        }

        return true;
    }