streams/Zotlabs/Lib/Yaml.php
2022-01-07 01:40:01 -08:00

33 lines
541 B
PHP

<?php
namespace Zotlabs\Lib;
use Symfony\Component\Yaml\Yaml as Syaml;
use Symfony\Component\Yaml\Exception\ParseException;
class Yaml
{
public static function decode($data)
{
try {
$value = Syaml::parse($data);
} catch (ParseException $exception) {
logger('Unable to parse the YAML string: ' . $exception->getMessage());
}
return $value;
}
public static function encode($data)
{
return Syaml::dump($data);
}
public static function fromJSON($data)
{
return Syaml::dump(json_decode($data,true));
}
}