. */ declare(strict_types=1); namespace App\EnvVarProcessors; use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; /** * Env var processor that adds a trailing slash to a string if not already present. */ final class AddSlashEnvVarProcessor implements EnvVarProcessorInterface { public function getEnv(string $prefix, string $name, \Closure $getEnv): mixed { $env = $getEnv($name); if (!is_string($env)) { throw new \InvalidArgumentException(sprintf('The "addSlash" env var processor only works with strings, got %s.', gettype($env))); } return rtrim($env, '/') . '/'; } public static function getProvidedTypes(): array { return [ 'addSlash' => 'string', ]; } }