public function generate()
    {
        $this->dirctoryName = $this->getPluginDir($this->name);

        $pluginDir = $this->targetDir.'/'.$this->dirctoryName;

        if (file_exists($pluginDir)) {
            throw new \RuntimeException(sprintf('Unable to generate the plugin as the plugin directory "%s" exists.', $pluginDir));
        }

        $model = [
            'name' => $this->name,
            'classname' => $this->getClassname($this->name),
            'namespace' => $this->namespace,
            'namespace_psr4' => $this->getNamespacePsr4($this->namespace),
            'author' => $this->author,
            'email' => $this->email,
            'description' => $this->description,
            'license' => $this->license,
        ];

        $this->cleanFilesAffected();

        $pluginTemplateFile = 'plugin/plugin.php.twig';

        if (empty($this->commandName) === false) {
            $pluginTemplateFile = 'plugin/commandPlugin.php.twig';

            $model['command_name'] = $this->commandName;
            $model['command_description'] = $this->commandDescription;
            $model['command_help'] = $this->commandHelp;
        }

        $this->renderFile($pluginTemplateFile, $pluginDir.'/'.$this->getPluginFilename($this->name), $model);
        $this->renderFile('plugin/composer.json.twig', $pluginDir.'/composer.json', $model);

        $licenseFile = $this->getLicenseFile($this->license);

        if ($licenseFile) {
            $model = [
                'author' => $this->author,
            ];

            $this->renderFile($licenseFile, $pluginDir.'/LICENSE', $model);
        }

        return $this->getFilesAffected();
    }