<commit_before><?php

namespace PlanMyLife\FrontBundle\Twig;

use Faker;

class FrontContentGeneratorExtension extends \Twig_Extension
{
    /**
     * @var FakerGeneratorExtension
     */
    private $fakerGenerator;

    /**
     * @var FrontElementsExtension
     */
    private $frontElements;

    /**
     * FrontContentGeneratorExtension constructor.
     * @param FakerGeneratorExtension $wordsGenerator
     * @param FrontElementsExtension $frontElements
     */
    public function __construct($wordsGenerator, $frontElements)
    {
        $this->fakerGenerator = $wordsGenerator;
        $this->frontElements = $frontElements;
    }

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

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        return array (
            new \Twig_SimpleFunction('fake_contribution', array($this, 'fake_contribution')),
        );
    }

    public function fake_contribution($long = false, $titleScope = [2, 6])
    {
        $contribution = '';

        foreach ($titleScope as $titleLevel) {
            $contribution .= $this->frontElements->title( 'H' . $titleLevel . ' - ' .$this->fakerGenerator->words(50, 150), $titleLevel );
            $contribution .= $this->fakerGenerator->words(100, 300);
        }

        $contribution = $this->fakerGenerator->words(50, 100);

        return $contribution;
    }
}<commit_msg>Build default contribution function<commit_after><?php

namespace PlanMyLife\FrontBundle\Twig;

use Faker;

class FrontContentGeneratorExtension extends \Twig_Extension
{
    /**
     * @var FakerGeneratorExtension
     */
    private $fakerGenerator;

    /**
     * @var FrontElementsExtension
     */
    private $frontElements;

    /**
     * FrontContentGeneratorExtension constructor.
     * @param FakerGeneratorExtension $wordsGenerator
     * @param FrontElementsExtension $frontElements
     */
    public function __construct($wordsGenerator, $frontElements)
    {
        $this->fakerGenerator = $wordsGenerator;
        $this->frontElements = $frontElements;
    }

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

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        return array (
            new \Twig_SimpleFunction('fake_contribution', array($this, 'fake_contribution')),
        );
    }

    /**
     * @param bool $long
     * @param array $titleScope
     * @return string
     */
    public function fake_contribution($long = false, $titleScope = [1, 6])
    {
        $contribution = '';

        for ($i = $titleScope[0]; $i <= $titleScope[1]; $i++) {
            $contribution .= $this->frontElements->title( 'H' . $i . ' - ' .$this->fakerGenerator->words(50, 150), $i );

            $contribution .= '<p>' . $this->fakerGenerator->words(100, 200) . '</p>';

            $nextParagraph = [];

            array_push($nextParagraph, $this->fakerGenerator->words(30, 100));

            if(rand(1, 100) > 50) {
                array_push($nextParagraph, '<strong>' . $this->fakerGenerator->words(30, 100) . '</strong>');
                array_push($nextParagraph, $this->fakerGenerator->words(30, 100));
            }

            if(rand(1, 100) > 50) {
                array_push($nextParagraph, '<i>' . $this->fakerGenerator->words(30, 100) . '</i>');
                array_push($nextParagraph, $this->fakerGenerator->words(30, 100));
            }

            if(rand(1, 100) > 50) {
                array_push($nextParagraph, $this->frontElements->link('#', $this->fakerGenerator->words(30, 100)));
                array_push($nextParagraph, $this->fakerGenerator->words(30, 100));
            }

            $contribution .= '<p>';
            $contribution .= implode(' ', $nextParagraph);
            $contribution .= '</p>';
        }

        $contribution .= '<p>';
        $contribution .= $this->frontElements->button('#', $this->fakerGenerator->words(20, 50));
        $contribution .= $this->frontElements->button('#', $this->fakerGenerator->words(20, 50));
        $contribution .= '</p>';

        $contribution .= $this->fakerGenerator->words(50, 100);

        return $contribution;
    }
}
{'fraction_non_alphanumeric': 0.15064695009242143, 'fraction_numerical': 0.022874306839186693, 'mean_word_length': 2.4086614173228345, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 60, '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': '3855054', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1230, 'n_words': 222}