osm-commerces/src/Twig/AppExtension.php
2025-08-22 17:58:13 +02:00

28 lines
No EOL
612 B
PHP

<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class AppExtension extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('repeat', [$this, 'repeatFilter']),
];
}
/**
* Repeats a string a specified number of times
*
* @param string $string The string to repeat
* @param int $times The number of times to repeat the string
* @return string The repeated string
*/
public function repeatFilter($string, $times)
{
return str_repeat($string, $times);
}
}