Files
2024-10-25 14:16:28 +02:00

50 lines
1.1 KiB
PHP

<?php
/**
* File from http://PrestaShow.pl
*
* DISCLAIMER
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future.
*
* @authors PrestaShow.pl <kontakt@prestashow.pl>
* @copyright 2015 PrestaShow.pl
* @license http://PrestaShow.pl/license
*/
use Symfony\Component\Yaml\Yaml;
class PShow_Yaml
{
/**
* Send the YAML representation of a value to a file
*
* @param string $filepath
* @param mixed $data
* @return boolean
*/
public static function emitToFile($filepath, $data)
{
if (function_exists('yaml_emit_file')) {
return yaml_emit_file($filepath, $data);
}
return file_put_contents($filepath, Yaml::dump($data));
}
/**
* Parse a YAML stream from a file
*
* @param string $filepath
* @return mixed
*/
public static function parseFile($filepath)
{
if (function_exists('yaml_parse_file')) {
return yaml_parse_file($filepath);
}
return Yaml::parse(file_get_contents($filepath));
}
}