<commit_before><?php
/**
 * Created by PhpStorm.
 * User: alan
 * Date: 12/17/14
 * Time: 12:28 PM
 */

namespace Mautic\CoreBundle\Helper;


use Mautic\CoreBundle\Factory\MauticFactory;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

/**
 * Class CacheHelper
 *
 * @package Mautic\CoreBundle\Helper
 */
class CacheHelper
{
    private $factory;

    /**
     * @param MauticFactory $factory
     */
    public function __construct(MauticFactory $factory)
    {
        $this->factory = $factory;
    }

    /**
     * Clear the application cache and run the warmup routine for the current environment
     *
     * @return void
     */
    public function clearCache()
    {
        ini_set('memory_limit', '128M');

        //attempt to squash command output
        ob_start();

        $env  = $this->factory->getEnvironment();
        $args = array('console', 'cache:clear', '--env=' . $env);

        if ($env == 'prod') {
            $args[] = '--no-debug';
        }

        $input       = new ArgvInput($args);
        $application = new Application($this->factory->getKernel());
        $application->setAutoExit(false);
        $application->run($input);

        if (ob_get_length() > 0) {
            ob_end_clean();
        }
    }

    /**
     * Delete's the file Symfony caches settings in
     */
    public function clearCacheFile()
    {
        $env      = $this->factory->getEnvironment();
        $debug    = ($this->factory->getDebugMode()) ? 'Debug' : '';
        $cacheDir = $this->factory->getSystemPath('cache', true);

        $cacheFile = "$cacheDir/app".ucfirst($env)."{$debug}ProjectContainer.php";

        if (file_exists($cacheFile)) {
            unlink($cacheFile);
        }
    }
}<commit_msg>Fixed wrong namespace in CacheHelper that resulted in the cache not getting cleared<commit_after><?php
/**
 * Created by PhpStorm.
 * User: alan
 * Date: 12/17/14
 * Time: 12:28 PM
 */

namespace Mautic\CoreBundle\Helper;

use Mautic\CoreBundle\Factory\MauticFactory;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

/**
 * Class CacheHelper
 *
 * @package Mautic\CoreBundle\Helper
 */
class CacheHelper
{
    private $factory;

    /**
     * @param MauticFactory $factory
     */
    public function __construct(MauticFactory $factory)
    {
        $this->factory = $factory;
    }

    /**
     * Clear the application cache and run the warmup routine for the current environment
     *
     * @param bool $noWarmup Skips the warmup routine
     *
     * @return void
     */
    public function clearCache($noWarmup = false)
    {
        // Force a refresh of enabled addon bundles so they are picked up by the events
        $addonHelper = $this->factory->getHelper('addon');
        $addonHelper->buildAddonCache();

        ini_set('memory_limit', '128M');

        //attempt to squash command output
        ob_start();

        $env  = $this->factory->getEnvironment();
        $args = array('console', 'cache:clear', '--env=' . $env);

        if ($env == 'prod') {
            $args[] = '--no-debug';
        }

        if ($noWarmup) {
            $args[] = '--no-warmup';
        }

        $input       = new ArgvInput($args);
        $application = new Application($this->factory->getKernel());
        $application->setAutoExit(false);
        $application->run($input);

        if (ob_get_length() > 0) {
            ob_end_clean();
        }
    }

    /**
     * Deletes the cache folder
     */
    public function nukeCache()
    {
        $cacheDir = $this->factory->getSystemPath('cache', true);

        $fs = new \Symfony\Component\Filesystem\Filesystem();
        $fs->remove($cacheDir);
    }

    /**
     * Delete's the file Symfony caches settings in
     */
    public function clearCacheFile()
    {
        $env      = $this->factory->getEnvironment();
        $debug    = ($this->factory->getDebugMode()) ? 'Debug' : '';
        $cacheDir = $this->factory->getSystemPath('cache', true);

        $cacheFile = "$cacheDir/app".ucfirst($env)."{$debug}ProjectContainer.php";

        if (file_exists($cacheFile)) {
            unlink($cacheFile);
        }
    }
}
{'fraction_non_alphanumeric': 0.14545884578997162, 'fraction_numerical': 0.006622516556291391, 'mean_word_length': 2.301327088212334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '1779938', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1248, 'n_words': 274}