<commit_before><?php

namespace Console\Thumbnails;

use Common\Core\Model;
use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;

/**
 * This is a simple command to generate thumbnails
 */
class GenerateThumbnailsCommand extends Command
{
    /**
     * Configure the command options.
     */
    protected function configure()
    {
        $this->setName('forkcms:thumbnails:generate')
            ->setAliases(['thumbnails:generate'])
            ->setDescription('Create thumbnails')
            ->addOption('folder', 'f', InputOption::VALUE_OPTIONAL, 'Name of the folder in /src/Frontend/Files where you want to generate thumbnails for.');
    }

    /**
     * Execute the command.
     *
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return int|null|void
     * @throws Exception
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Get input values
        $folderOption = $input->getOption('folder');

        if (!isset($folderOption)) {
            throw new Exception('Please specify a foldername "--folder=XXX"');
        }

        // Get path to locale file
        $folderPath = $this->getFolderPath($folderOption);

        $this->generateThumbnails($folderPath, $output);
    }

    /**
     * @param string $folderPath
     * @param OutputInterFace $output
     *
     * @throws Exception
     */
    private function generateThumbnails($folderPath, $output)
    {
        $finder = new Finder();
        $finder->files()->in($folderPath)->name('/^.*\.(jpg|jpeg|png|gif)$/i');

        foreach ($finder as $file) {
            Model::generateThumbnails($folderPath, $file->getRealPath());
            $output->writeln('<info>Creating thumbnail for ' . $file->getBasename() . '...</info>');
        }
    }

    /**
     * Get the folder path according to the input options
     *
     * @param string $folderOption
     *
     * @return string
     */
    private function getFolderPath($folderOption)
    {
        return __DIR__ . '/../../..' . '/src/Frontend/Files/' . $folderOption;
    }
}<commit_msg>typehint added<commit_after><?php

namespace Console\Thumbnails;

use Common\Core\Model;
use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;

/**
 * This is a simple command to generate thumbnails
 */
class GenerateThumbnailsCommand extends Command
{
    /**
     * Configure the command options.
     */
    protected function configure()
    {
        $this->setName('forkcms:thumbnails:generate')
            ->setAliases(['thumbnails:generate'])
            ->setDescription('Create thumbnails')
            ->addOption('folder', 'f', InputOption::VALUE_OPTIONAL, 'Name of the folder in /src/Frontend/Files where you want to generate thumbnails for.');
    }

    /**
     * Execute the command.
     *
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return int|null|void
     * @throws Exception
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Get input values
        $folderOption = $input->getOption('folder');

        if (!isset($folderOption)) {
            throw new Exception('Please specify a foldername "--folder=XXX"');
        }

        // Get path to locale file
        $folderPath = $this->getFolderPath($folderOption);

        $this->generateThumbnails($folderPath, $output);
    }

    /**
     * @param string $folderPath
     * @param OutputInterface $output
     * @throws Exception
     */
    private function generateThumbnails(string $folderPath, OutputInterface $output)
    {
        $finder = new Finder();
        $finder->files()->in($folderPath)->name('/^.*\.(jpg|jpeg|png|gif)$/i');

        foreach ($finder as $file) {
            Model::generateThumbnails($folderPath, $file->getRealPath());
            $output->writeln('<info>Creating thumbnail for ' . $file->getBasename() . '...</info>');
        }
    }

    /**
     * Get the folder path according to the input options
     *
     * @param string $folderOption
     * @return string
     */
    private function getFolderPath(string $folderOption): string
    {
        return __DIR__ . '/../../..' . '/src/Frontend/Files/' . $folderOption;
    }
}
{'fraction_non_alphanumeric': 0.1348097183401419, 'fraction_numerical': 0.0, 'mean_word_length': 2.6862123613312203, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, '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': '5446197', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1293, 'n_words': 297}