YamlInline::load PHP Method

load() public static method

Load YAML into a PHP array.
public static load ( $value ) : array
return array PHP array
    public static function load($value)
    {
        $value = trim($value);
        if (0 == strlen($value)) {
            return '';
        }
        switch ($value[0]) {
            case '[':
                return self::parseSequence($value);
            case '{':
                return self::parseMapping($value);
            default:
                return self::parseScalar($value);
        }
    }

Usage Example

 /**
  * Parses a YAML value.
  *
  * @param  string A YAML value
  *
  * @return mixed  A PHP value
  */
 protected function parseValue($value)
 {
     if ('*' === substr($value, 0, 1)) {
         if (false !== ($pos = strpos($value, '#'))) {
             $value = substr($value, 1, $pos - 2);
         } else {
             $value = substr($value, 1);
         }
         if (!array_key_exists($value, $this->refs)) {
             throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine));
         }
         return $this->refs[$value];
     }
     if (preg_match('/^(?P<separator>\\||>)(?P<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?P<comments> +#.*)?$/', $value, $matches)) {
         $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
         return $this->parseFoldedScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), intval(abs($modifiers)));
     } else {
         return YamlInline::load($value);
     }
 }