Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangjchandler committed Oct 4, 2023
1 parent f4fe5d7 commit 23d0829
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Drivers/Yaml.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Orbit\Drivers;

use Orbit\Contracts\Driver;
use Symfony\Component\Yaml\Yaml as YamlParser;

class Yaml implements Driver
{
public function parse(string $fileContents): array
{
return YamlParser::parse($fileContents);
}

public function compile(array $attributes): string
{
return YamlParser::dump($attributes);
}

public function extension(): string
{
return 'yml';
}
}
18 changes: 18 additions & 0 deletions tests/Unit/Drivers/YamlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Orbit\Drivers\Yaml;

it('can parse a yaml file into an array of attributes', function () {
$yaml = <<<'YML'
name: Ryan
email: "[email protected]"
YML;

$driver = new Yaml();

expect($driver->parse($yaml))
->toBe([
'name' => 'Ryan',
'email' => '[email protected]',
]);
});

0 comments on commit 23d0829

Please sign in to comment.