You are here

public static function JsonHelper::decodeParams in GraphQL 8.4

Decode encoded values recursively.

Parameters

array $values: The values to decode.

Return value

array The decoded values.

3 calls to JsonHelper::decodeParams()
QueryRouteEnhancer::extractBody in src/Routing/QueryRouteEnhancer.php
Extracts the body parameters from a request.
QueryRouteEnhancer::extractMultipart in src/Routing/QueryRouteEnhancer.php
Handles file uploads from multipart/form-data requests.
QueryRouteEnhancer::extractQuery in src/Routing/QueryRouteEnhancer.php
Extracts the query parameters from a request.

File

src/GraphQL/Utility/JsonHelper.php, line 19

Class

JsonHelper
JSON decoder for GraphQL parameters.

Namespace

Drupal\graphql\GraphQL\Utility

Code

public static function decodeParams(array $values = []) {
  return array_map(function ($value) {
    if (!is_string($value)) {
      return $value;
    }
    if (($decoded = json_decode($value, TRUE)) !== NULL && $decoded != $value) {
      return is_array($decoded) ? static::decodeParams($decoded) : $decoded;
    }
    return $value;
  }, $values);
}