Skip to content

Commit

Permalink
Added line break at the end of json and yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Feb 15, 2024
1 parent 1b54723 commit 780bec7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/Fixers/JsonFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ protected function parser(): JsonParser

protected function convert(string $json): string
{
return json_encode(
$encoded = json_encode(
json_decode($json, false),
JSON_UNESCAPED_UNICODE ^ JSON_UNESCAPED_SLASHES ^ JSON_PRETTY_PRINT
);

return trim($encoded) . PHP_EOL;
}
}
4 changes: 3 additions & 1 deletion app/Fixers/YamlFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected function parse(string $yaml): ?array

protected function encode(array $data): string
{
return Yaml::dump($data, 5);
$encoded = Yaml::dump($data, 5);

return trim($encoded) . PHP_EOL;
}
}

0 comments on commit 780bec7

Please sign in to comment.