<commit_before><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Manager;

use Doctrine\ORM\EntityManager;
use mgate\SuiviBundle\Entity\Etude as Etude;

class EtudeManager extends \Twig_Extension
{
    protected $em;
    protected $tva;

    public function __construct(EntityManager $em, $tva)
    {
        $this->em = $em;
        $this->tva = $tva;
    }

    // Pour utiliser les fonctions depuis twig
    public function getName()
    {
        return 'mgate_EtudeManager';
    }

    // Pour utiliser les fonctions depuis twig
    public function getFunctions()
    {
        return array(
            'getErrors' => new \Twig_Function_Method($this, 'getErrors'),
            'getWarnings' => new \Twig_Function_Method($this, 'getWarnings'),
            'getInfos' => new \Twig_Function_Method($this, 'getInfos'),
            'getEtatDoc' => new \Twig_Function_Method($this, 'getEtatDoc'),
            'getEtatFacture' => new \Twig_Function_Method($this, 'getEtatFacture'),
            'confidentielRefus' => new \Twig_Function_Method($this, 'confidentielRefus'),
        );
    }

    /***
     *
     * Juste un test
     */
     public function getFilters()
     {
         return array(
            'nbsp' => new \Twig_Filter_Method($this, 'nonBreakingSpace'),
            'string' => new \Twig_Filter_Method($this, 'toString'),
        );
     }

    public function toString($int)
    {
        return (string) $int;
    }

    public function nonBreakingSpace($string)
    {
        return preg_replace('#\s#', '&nbsp;', $string);
    }

    public function confidentielRefus(Etude $etude, $userToken)
    {
        try {
            $user = $userToken->getToken()->getUser()->getPersonne();

            if ($etude->getConfidentiel() && !$userToken->isGranted('ROLE_CA')) {
                if ($etude->getSuiveur() && $user->getId() != $etude->getSuiveur()->getId()) {
                    return true;
                }
            }
        } catch (Exception $e) {
            return true;
        }
    }

    /**
     * Get montant total TTC.
     */
    public function getTotalTTC(Etude $etude)
    {
        return round($etude->getMontantHT() * (1 + $this->tva), 2);
    }

    /**
     * Get nombre de JEH.
     */
    public function getMontantVerse(Etude $etude)
    {
        $total = 0;

        foreach ($etude->getMissions() as $mission) {<commit_msg>add phpdoc<commit_after><?php

/*
 * This file is part of the Incipio package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace mgate\SuiviBundle\Manager;

use Doctrine\ORM\EntityManager;
use mgate\SuiviBundle\Entity\Etude as Etude;

class EtudeManager extends \Twig_Extension
{
    protected $em;
    protected $tva;

    public function __construct(EntityManager $em, $tva)
    {
        $this->em = $em;
        $this->tva = $tva;
    }

    // Pour utiliser les fonctions depuis twig
    public function getName()
    {
        return 'mgate_EtudeManager';
    }

    // Pour utiliser les fonctions depuis twig
    public function getFunctions()
    {
        return array(
            'getErrors' => new \Twig_Function_Method($this, 'getErrors'),
            'getWarnings' => new \Twig_Function_Method($this, 'getWarnings'),
            'getInfos' => new \Twig_Function_Method($this, 'getInfos'),
            'getEtatDoc' => new \Twig_Function_Method($this, 'getEtatDoc'),
            'getEtatFacture' => new \Twig_Function_Method($this, 'getEtatFacture'),
            'confidentielRefus' => new \Twig_Function_Method($this, 'confidentielRefus'),
        );
    }

    /***
     *
     * Juste un test
     */
     public function getFilters()
     {
         return array(
            'nbsp' => new \Twig_Filter_Method($this, 'nonBreakingSpace'),
            'string' => new \Twig_Filter_Method($this, 'toString'),
        );
     }

    public function toString($int)
    {
        return (string) $int;
    }

    public function nonBreakingSpace($string)
    {
        return preg_replace('#\s#', '&nbsp;', $string);
    }

    public function confidentielRefus(Etude $etude, $userToken)
    {
        try {
            $user = $userToken->getToken()->getUser()->getPersonne();

            if ($etude->getConfidentiel() && !$userToken->isGranted('ROLE_CA')) {
                if ($etude->getSuiveur() && $user->getId() != $etude->getSuiveur()->getId()) {
                    return true;
                }
            }
        } catch (Exception $e) {
            return true;
        }
    }

    /**
     * Get montant total TTC.
     * @param Etude $etude
     * @return float
     */
    public function getTotalTTC(Etude $etude)
    {
        return round($etude->getMontantHT() * (1 + $this->tva), 2);
    }

    /**
     * Get nombre de JEH.
     * @param Etude $etude
     * @return float
     */
    public function getMontantVerse(Etude $etude)
    {
        $total = 0;

        foreach ($etude->getMissions() as $mission) {
{'fraction_non_alphanumeric': 0.13358851674641148, 'fraction_numerical': 0.0011483253588516747, 'mean_word_length': 2.1943765281173593, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, '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': '6072963', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1628, 'n_words': 369}