JsonPath   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 10
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 3 1
1
<?php
2
3
namespace Drupal\graphql_json\Plugin\GraphQL\Fields;
4
5
use Drupal\Component\Utility\NestedArray;
6
use Drupal\graphql\GraphQL\Execution\ResolveContext;
7
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
8
use GraphQL\Type\Definition\ResolveInfo;
9
10
/**
11
 * Traverse json objects with an array of path elements.
12
 *
13
 * @GraphQLField(
14
 *   id = "json_path",
15
 *   secure = true,
16
 *   name = "path",
17
 *   type = "JsonNode",
18
 *   parents = {"JsonObject", "JsonList"},
19
 *   arguments={
20
 *     "steps" = {
21
 *       "type" = "String",
22
 *       "multi" = true
23
 *     }
24
 *   }
25
 * )
26
 */
27
class JsonPath extends FieldPluginBase {
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
33
    yield NestedArray::getValue($value, $args['steps']);
34
  }
35
36
}
37