diff --git a/ecs.php b/ecs.php index b49a1179e..ddd9491ad 100644 --- a/ecs.php +++ b/ecs.php @@ -46,7 +46,7 @@ return static function (ContainerConfigurator $containerConfigurator): void { $parameters = $containerConfigurator->parameters(); - $parameters->set('sets', ['clean-code', 'common', 'php70', 'php71', 'psr12', 'symfony', 'symfony-risky']); + $parameters->set('sets', ['clean-code', 'common', 'php-70', 'php-71', 'psr-12', 'symfony', 'symfony-risky']); $parameters->set('paths', [ __DIR__ . '/src', diff --git a/src/Twig/TextExtension.php b/src/Twig/TextExtension.php index d29b85ad8..1dbd57afb 100644 --- a/src/Twig/TextExtension.php +++ b/src/Twig/TextExtension.php @@ -30,6 +30,7 @@ public function getFilters(): array new TwigFilter('ucwords', [$this, 'ucwords']), new TwigFilter('preg_replace', [$this, 'pregReplace']), new TwigFilter('format_bytes', [$this, 'formatBytes']), + new TwigFilter('url_decode', [$this, 'urlDecode']), ]; } @@ -84,4 +85,23 @@ public function formatBytes(int $bytes, int $precision = 2): string return round($bytes, $precision) . ' ' . $units[$pow]; } + + public function urlDecode(string $string) + { + if (! mb_strpos($string, '=')) { + return urldecode($string); + } + + $params = []; + + foreach (explode('&', $string) as $chunk) { + $param = explode('=', $chunk); + + if ($param) { + $params[urldecode($param[0])] = urldecode($param[1]); + } + } + + return $params; + } }