EscolaLMS/Templates-PDF

View on GitHub
src/Parsers/VarsParser.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace EscolaLms\TemplatesPdf\Parsers;

use Illuminate\Support\Str;

class VarsParser
{
    public static function parseVars(?array $vars = []): array
    {
        return collect($vars)
            ->filter(fn($var, $key) => !Str::contains($key, 'Global'))
            ->mapWithKeys(fn($var, $key) => [Str::snake(Str::replace("@", '', $key)) => $var])
            ->toArray();
    }
}