Commit 63719b40 authored by Anton Smirnov's avatar Anton Smirnov

Yaml dumper/loader proxy class

parent 182331d5
<?php
namespace SandFox\ComposerYaml\Helpers;
use Symfony\Component\Yaml\Yaml;
/**
* @internal
*/
class YamlHelper
{
/**
* @param mixed $value
* @return string
*/
public static function encode($value)
{
if (function_exists('yaml_emit')) {
// use ext-yaml
return yaml_emit($value);
} else {
// fall back to symfony/yaml
return Yaml::dump($value);
}
}
/**
* @param string $value
* @return mixed
*/
public static function decode($value)
{
if (function_exists('yaml_parse')) {
// use ext-yaml
return yaml_parse($value);
} else {
// fall back to symfony/yaml
return Yaml::parse($value);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment