<commit_before><?php

namespace Eschmar\TimeAgoBundle\Twig;

use Symfony\Contracts\Translation\TranslatorInterface;

/**
 * Provides a simple twig filter for expressing time difference in words.
 *
 * @author <NAME>, @eschmar
 **/
class TimeAgoExtension extends \Twig\Extension\AbstractExtension
{
    const TRANSLATION_NAMESPACE = 'time_ago';

    /**
     * @var TranslatorInterface
     **/
    private $translator;

    /**
     * @var string
     **/
    private $format;

    public function __construct(TranslatorInterface $translator, $format)
    {
        $this->translator = $translator;
        $this->format = $format;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'time_ago_extension';
    }

    /**
     * {@inheritdoc}
     */
    public function getFilters()
    {
        return [
            new \Twig\TwigFilter('ago', [$this, 'agoFilter']),
        ];
    }

    /**
     * Returns relative time in words (translated).
     *
     * @return string
     * @author <NAME>, @eschmar
     **/
    public function agoFilter(\DateTime $date, $format = null)
    {
        $diff = time() - $date->format('U');
        $format = $format ? $format : $this->format;

        $prefix = self::TRANSLATION_NAMESPACE;
        $prefix .= $diff > -5 ? '.past' : '.future';
<commit_msg>Use DateTimeInterface instead of DateTime<commit_after><?php

namespace Eschmar\TimeAgoBundle\Twig;

use Symfony\Contracts\Translation\TranslatorInterface;

/**
 * Provides a simple twig filter for expressing time difference in words.
 *
 * @author <NAME>, @eschmar
 **/
class TimeAgoExtension extends \Twig\Extension\AbstractExtension
{
    const TRANSLATION_NAMESPACE = 'time_ago';

    /**
     * @var TranslatorInterface
     **/
    private $translator;

    /**
     * @var string
     **/
    private $format;

    public function __construct(TranslatorInterface $translator, $format)
    {
        $this->translator = $translator;
        $this->format = $format;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'time_ago_extension';
    }

    /**
     * {@inheritdoc}
     */
    public function getFilters()
    {
        return [
            new \Twig\TwigFilter('ago', [$this, 'agoFilter']),
        ];
    }

    /**
     * Returns relative time in words (translated).
     *
     * @return string
     * @author <NAME>, @eschmar
     **/
    public function agoFilter(\DateTimeInterface $date, $format = null)
    {
        $diff = time() - $date->format('U');
        $format = $format ? $format : $this->format;

        $prefix = self::TRANSLATION_NAMESPACE;
        $prefix .= $diff > -5 ? '.past' : '.future';

{'fraction_non_alphanumeric': 0.13986013986013987, 'fraction_numerical': 0.000736105999263894, 'mean_word_length': 2.302551640340219, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1747653', 'n_tokens_mistral': 841, 'n_tokens_neox': 822, 'n_words': 182}