<commit_before><?php

namespace Maverick\Console\Command\Build\Step;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use RuntimeException;

class InvalidateCacheBuildStep extends BuildStep
{
    /**
     * @var string
     */
    protected $directory;

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

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $directory = $this->getRoot() . '/' . $this->directory;

        $output->writeln('Invalidating cache directory:');
        $output->writeln(sprintf("\tDirectory:\t%s", $directory));

        if (is_dir($directory)) {
            $rmrf = sprintf('rm -rf "%s"', $directory);
            system($rmrf);
        }

        mkdir($directory);
    }<commit_msg>Updated how cache dir is removed<commit_after><?php

namespace Maverick\Console\Command\Build\Step;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class InvalidateCacheBuildStep extends BuildStep
{
    /**
     * @var string
     */
    protected $directory;

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

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $directory = $this->getRoot() . '/' . $this->directory;

        $output->writeln('Invalidating cache directory:');
        $output->writeln(sprintf("\tDirectory:\t%s", $directory));

        $this->rmdir($directory);

        mkdir($directory);
    }

    protected function rmdir(string $directory) {
        if (!is_dir($directory)) {
            return;
        }

        foreach (glob($directory . '/*') as $target) {
            if (is_dir($target)) {
                $this->rmdir($target);
                continue;
            }

            unlink($target);
        }

        rmdir($directory);
    }
{'fraction_non_alphanumeric': 0.13640730067243034, 'fraction_numerical': 0.0, 'mean_word_length': 2.4716666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4330875', 'n_tokens_mistral': 588, 'n_tokens_neox': 572, 'n_words': 111}