Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ConvertsArrayToFrontMatter | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
execute | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Hyde\Framework\Actions; |
6 | |
7 | use Symfony\Component\Yaml\Yaml; |
8 | |
9 | /** |
10 | * Convert an array into YAML Front Matter. |
11 | */ |
12 | class ConvertsArrayToFrontMatter |
13 | { |
14 | /** |
15 | * Execute the action. |
16 | * |
17 | * @return string $yaml front matter |
18 | */ |
19 | public function execute(array $array, int $flags = 0): string |
20 | { |
21 | if (empty($array)) { |
22 | return ''; |
23 | } |
24 | |
25 | return "---\n".Yaml::dump($array, flags: $flags)."---\n"; |
26 | } |
27 | } |