Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
artengin committed Aug 4, 2024
1 parent e9801ad commit afaf459
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ function parser(string $path): array

$content = file_get_contents($path);
$extension = pathinfo($path, PATHINFO_EXTENSION);
var_dump($content);
return match ($extension) {
"json" => jsonFileParse($content),
"yml", "yaml" => yamlFileParse($content),
default => throw new \Exception("Format {$extension} not supported."),
};
}

function jsonFileParse(string $data): array
function jsonFileParse($data): array
{
return json_decode($data, true, 512, JSON_THROW_ON_ERROR);
}

function yamlFileParse(string $data): array
function yamlFileParse($data): array
{
return Yaml::parse($data);
}

0 comments on commit afaf459

Please sign in to comment.