<commit_before><?php

/**
 * This file is part of tenside/core-bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * This project is provided in good faith and hope to be usable by anyone.
 *
 * @package    tenside/core-bundle
 * @author     <NAME> <<EMAIL>>
 * @copyright  2015 <NAME> <<EMAIL>>
 * @license    https://github.com/tenside/core-bundle/blob/master/LICENSE MIT
 * @link       https://github.com/tenside/core-bundle
 * @filesource
 */

namespace Tenside\CoreBundle\Command;

use Composer\Command\BaseCommand;
use Composer\Downloader\FilesystemException;
use Composer\Factory;
use Composer\Util\Filesystem;
use Composer\Util\RemoteFilesystem;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Finder\Finder;
use Tenside\Core\Tenside;

/**
 * Update the phar.
 *
 * This class is a heavily influenced (copied and modified) version of the composer self-update command
 *
 * @see Composer\Command\SelfUpdateCommand
 */
class SelfUpdateCommand extends BaseCommand implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    /**
     * The remote file system to use.
     *
     * @var RemoteFilesystem
     */
    private $rfs;

    /**
     * Buffer the base url value.
     *
     * @var string
     */
    private $baseUrl;

    /**
     * Backup file name.
     */
    const OLD_INSTALL_EXT = '-old.phar';

    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('tenside:self-update')
            ->setAliases(['tenside:selfupdate'])
            ->setDescription('Updates tenside.phar to the latest version.')
            ->setDefinition(array(
                new InputOption(
                    'rollback',
                    'r',
                    InputOption::VALUE_NONE,
                    'Revert to an older version'
                ),
                new InputOption(
                    'clean-backups',
                    null,
                    InputOption::VALUE_NONE,
                    'Delete old backups during an update. ' .
                    'This makes the current version of the only backup available after the update'
                ),
                new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
                new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
            ))
            ->setHelp(
                'The <info>self-update</info> command checks the update server for newer
versions and if found, installs the latest.

<info>php tenside.phar self-update</info>

'
            );
    }

    /**
     * {@inheritDoc}
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     *
     * @throws FilesystemException When the temporary directory or local file are not writable.
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $originName    = $this->getOriginName();
        $config        = Factory::createConfig();
        $inputOutput   = $this->getIO();
        $this->rfs     = new RemoteFilesystem($inputOutput, $config);
        $cacheDir      = $config->get('cache-dir');
        $rollbackDir   = $config->get('home');
        $localFilename = $this->determineLocalFileName();

        // check if current dir is writable and if not try the cache dir from settings
        $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;

        // check for permissions in local filesystem before start connection process
        if (!is_writable($tmpDir)) {
            throw new FilesystemException(
                sprintf(
                    'Self update failed: the "%s" directory used to download the temp file could not be written',
                    $tmpDir
                )
            );
        }
        if (!is_writable($localFilename)) {
            throw new FilesystemException('Self update failed: the "'.$localFilename.'" file could not be written');
        }
<commit_msg>Rephrase error message<commit_after><?php

/**
 * This file is part of tenside/core-bundle.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * This project is provided in good faith and hope to be usable by anyone.
 *
 * @package    tenside/core-bundle
 * @author     <NAME> <<EMAIL>>
 * @copyright  2015 <NAME> <<EMAIL>>
 * @license    https://github.com/tenside/core-bundle/blob/master/LICENSE MIT
 * @link       https://github.com/tenside/core-bundle
 * @filesource
 */

namespace Tenside\CoreBundle\Command;

use Composer\Command\BaseCommand;
use Composer\Downloader\FilesystemException;
use Composer\Factory;
use Composer\Util\Filesystem;
use Composer\Util\RemoteFilesystem;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Finder\Finder;
use Tenside\Core\Tenside;

/**
 * Update the phar.
 *
 * This class is a heavily influenced (copied and modified) version of the composer self-update command
 *
 * @see Composer\Command\SelfUpdateCommand
 */
class SelfUpdateCommand extends BaseCommand implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    /**
     * The remote file system to use.
     *
     * @var RemoteFilesystem
     */
    private $rfs;

    /**
     * Buffer the base url value.
     *
     * @var string
     */
    private $baseUrl;

    /**
     * Backup file name.
     */
    const OLD_INSTALL_EXT = '-old.phar';

    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        $this
            ->setName('tenside:self-update')
            ->setAliases(['tenside:selfupdate'])
            ->setDescription('Updates tenside.phar to the latest version.')
            ->setDefinition(array(
                new InputOption(
                    'rollback',
                    'r',
                    InputOption::VALUE_NONE,
                    'Revert to an older version'
                ),
                new InputOption(
                    'clean-backups',
                    null,
                    InputOption::VALUE_NONE,
                    'Delete old backups during an update. ' .
                    'This makes the current version of the only backup available after the update'
                ),
                new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
                new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
            ))
            ->setHelp(
                'The <info>self-update</info> command checks the update server for newer
versions and if found, installs the latest.

<info>php tenside.phar self-update</info>

'
            );
    }

    /**
     * {@inheritDoc}
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
     *
     * @throws FilesystemException When the temporary directory or local file are not writable.
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $originName    = $this->getOriginName();
        $config        = Factory::createConfig();
        $inputOutput   = $this->getIO();
        $this->rfs     = new RemoteFilesystem($inputOutput, $config);
        $cacheDir      = $config->get('cache-dir');
        $rollbackDir   = $config->get('home');
        $localFilename = $this->determineLocalFileName();

        // check if current dir is writable and if not try the cache dir from settings
        $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;

        // check for permissions in local filesystem before start connection process
        if (!is_writable($tmpDir)) {
            throw new FilesystemException(
                sprintf(
                    'Self update failed: the "%s" directory used to download the temp file could not be written',
                    $tmpDir
                )
            );
        }
        if (!is_writable($localFilename)) {
            throw new FilesystemException('Self update failed: "' . $localFilename . '" is not writable.');
        }

{'fraction_non_alphanumeric': 0.10257810793095914, 'fraction_numerical': 0.0008739348918505571, 'mean_word_length': 2.3375865840320817, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 51, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5196072', 'n_tokens_mistral': 2473, 'n_tokens_neox': 2429, 'n_words': 657}