Converts a YAML string to a PHP array.
string $value A YAML string:
array A PHP array representing the YAML string
public static function parse($value) {
$value = trim($value);
if (0 == strlen($value)) {
return '';
}
if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
switch ($value[0]) {
case '[':
$result = self::parseSequence($value);
break;
case '{':
$result = self::parseMapping($value);
break;
default:
$i = 0;
$result = self::parseScalar($value, null, array(
'"',
"'",
), $i);
// some comment can end the scalar
if (preg_replace('/\\s+#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
}
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
return $result;
}