<commit_before><?php
declare(strict_types=1);
/**
 * /src/App/Command/Utils/PopulateDateDimensionCommand.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Command\Utils;

use App\Entity\DateDimension;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMInvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

/**
 * Class PopulateDateDimensionCommand
 *
 * @package App\Command\Utils
 * @author  TLe, <NAME> <<EMAIL>>
 */
class PopulateDateDimensionCommand extends ContainerAwareCommand
{
    const YEAR_MIN = 1970;
    const YEAR_MAX = 2047; // This should be the year when I'm officially retired

    /**
     * @var SymfonyStyle
     */
    private $io;

    /**
     * {@inheritdoc}
     *
     * @throws InvalidArgumentException
     */
    protected function configure()
    {
        // Configure command
        $this
            ->setName('utils:populateDateDimension')
            ->setDescription('Console command to populate \'date_dimension\' table.')
        ;
    }

    /**
     * {@inheritdoc}
     *
     * @throws \RuntimeException
     * @throws \LogicException
     * @throws ServiceCircularReferenceException
     * @throws ServiceNotFoundException
     * @throws ORMInvalidArgumentException
     * @throws OptimisticLockException
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Create output decorator helpers for the Symfony Style Guide.
        $this->io = new SymfonyStyle($input, $output);

        // Set title
        $this->io->title($this->getDescription());

        // Determine start and end years
        $yearStart = $this->getYearStart();
        $yearEnd = $this->getYearEnd($yearStart);

        // Create actual entities
        $this->createEntities($yearStart, $yearEnd);

        $this->io->success('All done - have a nice day!');
    }

    /**
     * Method to get start year value from user.
     *
     * @throws \RuntimeException
     *
     * @return int
     */
    private function getYearStart(): int
    {
        /**
         * Lambda validator function for start year io question.<commit_msg>Small refactor.<commit_after><?php
declare(strict_types=1);
/**
 * /src/App/Command/Utils/PopulateDateDimensionCommand.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Command\Utils;

use App\Entity\DateDimension;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMInvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

/**
 * Class PopulateDateDimensionCommand
 *
 * @package App\Command\Utils
 * @author  TLe, <NAME> <<EMAIL>>
 */
class PopulateDateDimensionCommand extends ContainerAwareCommand
{
    const YEAR_MIN = 1970;
    const YEAR_MAX = 2047; // This should be the year when I'm officially retired

    /**
     * @var SymfonyStyle
     */
    private $io;

    /**
     * {@inheritdoc}
     *
     * @throws InvalidArgumentException
     */
    protected function configure()
    {
        // Configure command
        $this
            ->setName('utils:populateDateDimension')
            ->setDescription('Console command to populate \'date_dimension\' table.')
        ;
    }

    /**
     * Executes the current command.
     *
     * @throws  \LogicException
     * @throws  \RuntimeException
     * @throws  OptimisticLockException
     * @throws  ORMInvalidArgumentException
     * @throws  ServiceCircularReferenceException
     * @throws  ServiceNotFoundException
     *
     * @param   InputInterface $input An InputInterface instance
     * @param   OutputInterface $output An OutputInterface instance
     *
     * @return  void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Create output decorator helpers for the Symfony Style Guide.
        $this->io = new SymfonyStyle($input, $output);

        // Set title
        $this->io->title($this->getDescription());

        // Determine start and end years
        $yearStart = $this->getYearStart();
        $yearEnd = $this->getYearEnd($yearStart);

        // Create actual entities
        $this->createEntities($yearStart, $yearEnd);

        $this->io->success('All done - have a nice day!');
    }

    /**
     * Method to get start year value from user.
     *
     * @throws \RuntimeException
     *
     * @return int
     */
    private function getYearStart(): int
    {
        /**
         * Lambda validator function for start year io question.
{'fraction_non_alphanumeric': 0.10642644873699851, 'fraction_numerical': 0.0033432392273402673, 'mean_word_length': 3.024663677130045, 'pattern_counts': {'":': 0, '<': 17, '<?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': '5146594', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1450, 'n_words': 331}