<commit_before><?php

namespace Bolt\Composer\Action;

use Bolt\Exception\PackageManagerException;
use Composer\DependencyResolver\Pool;
use Composer\Factory;
use Composer\Package\Version\VersionParser;
use Composer\Package\Version\VersionSelector;
use Composer\Repository\ComposerRepository;
use Composer\Repository\ConfigurableRepositoryInterface;
use Silex\Application;

abstract class BaseAction
{
    /** @var array */
    protected $messages = [];
    /** @var \Silex\Application */
    protected $app;

    /** @var \Composer\IO\BufferIO */
    private $io;
    /** @var \Composer\Composer */
    private $composer;
    /** @var \Composer\DependencyResolver\Pool */
    private $pool;
    /** @var \Composer\Repository\CompositeRepository */
    private $repos;

    /**
     * Constructor.
     *
     * @param $app \Silex\Application
     */
    public function __construct(Application $app)
    {
        $this->app = $app;
    }

    /**
     * Return the output from the last IO.
     *
     * @return string
     */
    public function getOutput()
    {
        return $this->io->getOutput();
    }

    /**
     * Get a single option.
     *
     * @return Options
     */
    protected function getOptions()
    {
        return $this->app['extend.action.options'];
    }

    /**
     * Get a Composer object.
     *
     * @throws \Exception
     *
     * @return \Composer\Composer
     */
    protected function getComposer()
    {
        if (!$this->composer) {
            // Set composer environment variables
            putenv('COMPOSER_HOME=' . $this->app['path_resolver']->resolve('%cache%/composer'));

            // Set working directory
            chdir($this->getOptions()->baseDir());

            try {
                // Use the factory to get a new Composer object
                $this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
            } catch (\InvalidArgumentException $e) {
                throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
            } catch (\Exception $e) {
                $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
                throw $e;
            }

            // Add the event subscriber
            $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);

            if (!$this->app['extend.manager']->useSsl()) {
                $this->setAllowSslDowngrade(true);
            }
        }

        return $this->composer;<commit_msg>Move COMPOSER_HOME to var/composer/<commit_after><?php

namespace Bolt\Composer\Action;

use Bolt\Exception\PackageManagerException;
use Composer\DependencyResolver\Pool;
use Composer\Factory;
use Composer\Package\Version\VersionParser;
use Composer\Package\Version\VersionSelector;
use Composer\Repository\ComposerRepository;
use Composer\Repository\ConfigurableRepositoryInterface;
use Silex\Application;

abstract class BaseAction
{
    /** @var array */
    protected $messages = [];
    /** @var \Silex\Application */
    protected $app;

    /** @var \Composer\IO\BufferIO */
    private $io;
    /** @var \Composer\Composer */
    private $composer;
    /** @var \Composer\DependencyResolver\Pool */
    private $pool;
    /** @var \Composer\Repository\CompositeRepository */
    private $repos;

    /**
     * Constructor.
     *
     * @param $app \Silex\Application
     */
    public function __construct(Application $app)
    {
        $this->app = $app;
    }

    /**
     * Return the output from the last IO.
     *
     * @return string
     */
    public function getOutput()
    {
        return $this->io->getOutput();
    }

    /**
     * Get a single option.
     *
     * @return Options
     */
    protected function getOptions()
    {
        return $this->app['extend.action.options'];
    }

    /**
     * Get a Composer object.
     *
     * @throws \Exception
     *
     * @return \Composer\Composer
     */
    protected function getComposer()
    {
        if (!$this->composer) {
            // Set composer environment variables
            putenv('COMPOSER_HOME=' . $this->app['path_resolver']->resolve('%var%/composer'));

            // Set working directory
            chdir($this->getOptions()->baseDir());

            try {
                // Use the factory to get a new Composer object
                $this->composer = Factory::create($this->getIO(), $this->getOptions()->composerJson()->getPath(), false);
            } catch (\InvalidArgumentException $e) {
                throw new PackageManagerException($e->getMessage(), $e->getCode(), $e);
            } catch (\Exception $e) {
                $this->app['logger.system']->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
                throw $e;
            }

            // Add the event subscriber
            $this->composer->getEventDispatcher()->addSubscriber($this->app['extend.listener']);

            if (!$this->app['extend.manager']->useSsl()) {
                $this->setAllowSslDowngrade(true);
            }
        }

        return $this->composer;
{'fraction_non_alphanumeric': 0.1464451313755796, 'fraction_numerical': 0.0, 'mean_word_length': 2.17997542997543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5982358', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1434, 'n_words': 294}