<commit_before><?php declare(strict_types=1);

namespace SeStep\Moment;

use Nette\DI\CompilerExtension;
use Nette\DI\ServiceDefinition;

class MomentProviderExtension extends CompilerExtension
{
    public function loadConfiguration()
    {
        $builder = $this->getContainerBuilder();

        $builder->addDefinition($this->prefix('provider'))
            ->setType(RelativeMomentProvider::class)
            ->setArgument('now', new \DateTime());
    }
    
    public function beforeCompile()
    {
        $builder = $this->getContainerBuilder();

        $builder->getDefinition($this->prefix('provider'));

        foreach ($builder->getDefinitions() as $definition) {
            if (!$definition instanceof ServiceDefinition) {
                continue;
            }
            $class = $definition->getType();
            if (!class_exists($class)) {
                continue;
            }
            if (!in_array(HasMomentProvider::class, class_uses($class))) {
                continue;
            }

            $definition->addSetup('setMomentProvider');
        }
    }
}<commit_msg>Fix moment provider using compiled date instead of actual<commit_after><?php declare(strict_types=1);

namespace SeStep\Moment;

use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\Statement;
use Nette\DI\ServiceDefinition;

class MomentProviderExtension extends CompilerExtension
{
    public function loadConfiguration()
    {
        $builder = $this->getContainerBuilder();

        $builder->addDefinition($this->prefix('provider'))
            ->setType(RelativeMomentProvider::class)
            ->setArgument('now', new Statement(\DateTime::class));
    }
    
    public function beforeCompile()
    {
        $builder = $this->getContainerBuilder();

        $builder->getDefinition($this->prefix('provider'));

        foreach ($builder->getDefinitions() as $definition) {
            if (!$definition instanceof ServiceDefinition) {
                continue;
            }
            $class = $definition->getType();
            if (!class_exists($class)) {
                continue;
            }
            if (!in_array(HasMomentProvider::class, class_uses($class))) {
                continue;
            }

            $definition->addSetup('setMomentProvider');
        }
    }
}
{'fraction_non_alphanumeric': 0.12445980985306827, 'fraction_numerical': 0.000864304235090752, 'mean_word_length': 2.4144542772861355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2556956', 'n_tokens_mistral': 584, 'n_tokens_neox': 567, 'n_words': 104}