本文整理汇总了PHP中Spyc::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP Spyc::dump方法的具体用法?PHP Spyc::dump怎么用?PHP Spyc::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spyc
的用法示例。
在下文中一共展示了Spyc::dump方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDumpWithQuotes
public function testDumpWithQuotes()
{
$Spyc = new Spyc();
$Spyc->setting_dump_force_quotes = true;
$yaml = $Spyc->load(file_get_contents('../spyc.yaml'));
$dump = $Spyc->dump($yaml);
$yaml_after_dump = Spyc::YAMLLoad($dump);
$this->assertEquals($yaml, $yaml_after_dump);
}
示例2: testDumpWithQuotes
public function testDumpWithQuotes()
{
$Spyc = new Spyc();
$Spyc->setting_dump_force_quotes = true;
foreach ($this->files_to_test as $file) {
$yaml = $Spyc->load(file_get_contents($file));
$dump = $Spyc->dump($yaml);
$yaml_after_dump = Spyc::YAMLLoad($dump);
$this->assertEquals($yaml, $yaml_after_dump);
}
}
示例3: write
/**
* Write the config array to a yaml file.
*
* @param string The yaml file.
*
* @return bool True, if successfully written, else False.
*/
public static function write($file, array $array)
{
// prefer yaml, then syck, else use Spyc - faster one first
if (extension_loaded('yaml')) {
return yaml_emit_file($file, $array);
} elseif (extension_loaded('syck')) {
$yaml = syck_dump($array);
} elseif (class_exists('Spyc')) {
$spyc = new Spyc();
$yaml = $spyc->dump($array);
} else {
throw new \Koch\Exception\Exception('No YAML Parser available. Get Spyc or Syck!');
}
return (bool) file_put_contents($file, $yaml, LOCK_EX);
}
示例4: YAMLDump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @access public
* @return string
* @param array $array PHP array
* @param int $indent Pass in false to use the default, which is 2
* @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
* @param int $no_opening_dashes Do not start YAML file with "---\n"
*/
public static function YAMLDump($array, $indent = false, $wordwrap = false, $no_opening_dashes = false)
{
$spyc = new Spyc();
return $spyc->dump($array, $indent, $wordwrap, $no_opening_dashes);
}
示例5: YAMLDump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @access public
* @return string
* @param array $array PHP array
* @param int $indent Pass in false to use the default, which is 2
* @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
*/
function YAMLDump($array, $indent = false, $wordwrap = false)
{
$spyc = new Spyc();
return $spyc->dump($array, $indent, $wordwrap);
}
示例6: YAMLDump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yml and pass it around.
* @access public
* @return string
* @param array $array PHP array
*/
function YAMLDump($array)
{
$spyc = new Spyc();
return $spyc->dump($array);
}
示例7: dump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML.
*
* @return string
* @param array $array PHP array
*/
public static function dump($array)
{
require_once dirname(__FILE__) . '/Spyc.class.php';
$spyc = new Spyc();
return $spyc->dump($array, false, 0);
}
示例8: YAMLDump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @access public
* @return string
* @param array $array PHP array
* @param int $indent Pass in false to use the default, which is 2
* @param int $wordwrap Pass in 0 for no wordwrap, false for default (40)
*/
function YAMLDump($array, $indent = false, $wordwrap = false, $ignore_private = false)
{
$spyc = new Spyc();
return $spyc->dump($array, $indent, $wordwrap, $ignore_private);
}
示例9: write_state_file
/**
* Write a state object to a file
*
* @param object $state_obj
* @param string $file
*/
private function write_state_file($state_data, $file)
{
$spyc = new Spyc();
$file_data = $spyc->dump($state_data, 2, 0);
// $spyc->dump() prepends "---\n" :(
$file_data = substr($file_data, 4);
file_put_contents($file, $file_data);
}
示例10: dump
/**
* write yaml from an array using the Spyc class
* @param array $array array to YAMLize
* @return string
*/
public function dump($array)
{
return Spyc::dump($array);
}
示例11: yamlDump
/**
* Dump YAML from PHP array statically
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML. Pretty simple. Feel free to
* save the returned string as nothing.yaml and pass it around.
*
* Oh, and you can decide how big the indent is and what the wordwrap
* for folding is. Pretty cool -- just pass in 'false' for either if
* you want to use the default.
*
* Indent's default is 2 spaces, wordwrap's default is 40 characters. And
* you can turn off wordwrap by passing in 0.
*
* @param [array] $array PHP array
* @param [integer] $indent Pass in false to use the default, which is 2
* @param [integer] $wordwrap 0 for no wordwrap, false for default (40)
* @return [string] $string
*/
public static function yamlDump($array, $indent = false, $wordwrap = false)
{
$spyc = new Spyc();
$string = $spyc->dump($array, $indent, $wordwrap);
return $string;
}
示例12: writeConfig
/**
* Write the config array to a yaml file
*
* @param string The filename
* @return array | boolean false
* @todo fix this return true/false thingy
*/
public static function writeConfig($file, array $array)
{
/**
* transform PHP Array into YAML Format
*/
// take syck, as the faster one first
if (extension_loaded('syck')) {
// convert to YAML via SYCK
$yaml = syck_dump($data);
} elseif (is_file(ROOT_LIBRARIES . '/spyc/Spyc.class.php') === true) {
// ok, load spyc
if (false === class_exists('Spyc', false)) {
include ROOT_LIBRARIES . '/spyc/Spyc.class.php';
}
$spyc = new Spyc();
// convert to YAML via SPYC
$yaml = $spyc->dump($array);
} else {
// we have no YAML Parser - too bad :(
throw new Koch_Exception('No YAML Parser available. Get Spyc or Syck!');
}
/**
* write array
*/
// write YAML content to file
file_put_contents($file, $yaml);
}