<commit_before><?php

namespace Symfony\Installer;

use Distill\Distill;
use Distill\Strategy\MinimumSize;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Subscriber\Progress\Progress;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;

/**
 * This command creates new Symfony projects for the given Symfony version.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class NewCommand extends Command
{
    /**
     * @var Filesystem
     */
    private $fs;
    private $projectName;
    private $projectDir;
    private $version;
    private $compressedFilePath;

    protected function configure()
    {
        $this
            ->setName('new')
            ->setDescription('Creates a new Symfony project.')
            ->addArgument('name', InputArgument::REQUIRED, 'The name of the directory where the new project will be created')
            ->addArgument('version', InputArgument::OPTIONAL, 'The Symfony version to be installed (defaults to the latest stable version)', 'latest')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->fs = new Filesystem();
        $this->projectName = trim($input->getArgument('name'));
        $this->projectDir = rtrim(getcwd().DIRECTORY_SEPARATOR.$this->projectName, DIRECTORY_SEPARATOR);
        $this->version = trim($input->getArgument('version'));
        $this->output = $output;

        $this
            ->checkInstalledPhpVersion()
            ->checkProjectName()
            ->checkSymfonyVersionIsInstallable()
            ->download()
            ->extract()
            ->cleanUp()
            ->displayInstallationResult()
        ;
    }

    /**
     * Checks if the system has PHP 5.4 or higher installed, which is a requirement
     * to execute the installer.
     */
    private function checkInstalledPhpVersion()
    {
        if (version_compare(PHP_VERSION, '5.4.0', '<')) {
            throw new \RuntimeException(sprintf(
                "Symfony Installer requires PHP 5.4 version or higher and your system has\n".
                "PHP %s version installed.\n\n".
                "To solve this issue, upgrade your PHP installation or install Symfony manually\n".
                "executing the following command:\n\n".
                "composer create-project symfony/framework-standard-edition %s",
                PHP_VERSION, $this->projectName<commit_msg>feature #35 improve error message for PHP < 5.4 (xabbuh)<commit_after><?php

namespace Symfony\Installer;

use Distill\Distill;
use Distill\Strategy\MinimumSize;
use GuzzleHttp\Client;
use GuzzleHttp\Message\Response;
use GuzzleHttp\Subscriber\Progress\Progress;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;

/**
 * This command creates new Symfony projects for the given Symfony version.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class NewCommand extends Command
{
    /**
     * @var Filesystem
     */
    private $fs;
    private $projectName;
    private $projectDir;
    private $version;
    private $compressedFilePath;

    protected function configure()
    {
        $this
            ->setName('new')
            ->setDescription('Creates a new Symfony project.')
            ->addArgument('name', InputArgument::REQUIRED, 'The name of the directory where the new project will be created')
            ->addArgument('version', InputArgument::OPTIONAL, 'The Symfony version to be installed (defaults to the latest stable version)', 'latest')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->fs = new Filesystem();
        $this->projectName = trim($input->getArgument('name'));
        $this->projectDir = rtrim(getcwd().DIRECTORY_SEPARATOR.$this->projectName, DIRECTORY_SEPARATOR);
        $this->version = trim($input->getArgument('version'));
        $this->output = $output;

        $this
            ->checkInstalledPhpVersion()
            ->checkProjectName()
            ->checkSymfonyVersionIsInstallable()
            ->download()
            ->extract()
            ->cleanUp()
            ->displayInstallationResult()
        ;
    }

    /**
     * Checks if the system has PHP 5.4 or higher installed, which is a requirement
     * to execute the installer.
     */
    private function checkInstalledPhpVersion()
    {
        if (version_compare(PHP_VERSION, '5.4.0', '<')) {
            throw new \RuntimeException(sprintf(
                "Symfony Installer requires PHP 5.4 version or higher and your system has\n".
                "PHP %s version installed.\n\n".
                "To solve this issue, upgrade your PHP installation or install Symfony manually\n".
                "executing the following command:\n\n".
                "composer create-project symfony/framework-standard-edition %s %s",
                PHP_VERSION,
                $this->projectName,
                'latest' !== $this->version ? $this->version : ''
{'fraction_non_alphanumeric': 0.11254780549990895, 'fraction_numerical': 0.003278091422327445, 'mean_word_length': 2.6983164983164984, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7540972', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1449, 'n_words': 387}