<?php
namespace Modules\Additional\Specifique\Client118\Modules\EtatStatistique\TwigExtension;

use Psr\Container\ContainerInterface;
use Skeleton\Router;

class OutilExtension extends \Twig\Extension\AbstractExtension
{
    protected $pdo;
    protected $contenaire;
    
    public function __construct(\PDO $pdo, ContainerInterface $contenaire)
    {
        
        $this->pdo = $pdo;
        $this->contenaire = $contenaire;
    }
    
    public function getFilters()
    {
        return array(
            'montantAbreger' => new \Twig\TwigFilter('montantAbreger', array($this, 'montantAbreger')),
        );
    }
    
    public function montantAbreger($value)
    {
        $prixDeBase = str_replace(',', '.', $value);

        if ($prixDeBase) {
            $prixDeBase = ((float)$prixDeBase/1000);
            $value = number_format($prixDeBase, 2, '.', ' ');
        } else {
            $value = '0.00';
        }
        
        return $value;
    }
}
