lib/Helper.php
protected function parseArguments(string $text, string $defaultArgument, array $defaultValues = []): array {
    try {
      if (is_array($json = Json::decode($text))) return ArrayHelper::merge($defaultValues, $json);
      throw new InvalidArgumentException('The JSON string has an invalid format.');
    }

    catch (InvalidArgumentException $e) {
      $defaultValues[$defaultArgument] = $text;
      return $defaultValues;
    }
  }
protected function parseArguments(string $text, string $defaultArgument, array $defaultValues = []): array {
    try {
      if (is_array($json = Json::decode($text))) return ArrayHelper::merge($defaultValues, $json);
      throw new InvalidArgumentException('The JSON string has an invalid format.');
    }

    catch (InvalidArgumentException $e) {
      $defaultValues[$defaultArgument] = $text;
      return $defaultValues;
    }
  }
protected function parseArguments ( string $ text , string $ defaultArgument , array $ defaultValues = [ ] ) : array { try { if ( is_array ( $ json = Json :: decode ( $ text ) ) ) return ArrayHelper :: merge ( $ defaultValues , $ json ) ; throw new InvalidArgumentException ( 'The JSON string has an invalid format.' ) ; } catch ( InvalidArgumentException $ e ) { $ defaultValues [ $ defaultArgument ] = $ text ; return $ defaultValues ; } }
Parses the arguments of a parameterized helper.
Arguments can be specified as a single value, or as a string in JSON format.
@param string $text The section content specifying the helper arguments.
@param string $defaultArgument The name of the default argument. This is used when the section content provides a plain string instead of a JSON object.
@param array $defaultValues The default values of arguments. These are used when the section content does not specify all arguments.
@return array The parsed arguments as an associative array.
Parses the arguments of a parameterized helper . Arguments can be specified as a single value or as a string in JSON format .