JsonPathToUrl::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
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_core\Plugin\GraphQL\Fields\Routing\Route;
8
use GraphQL\Type\Definition\ResolveInfo;
9
10
/**
11
 * Extract Url objects from json paths.
12
 *
13
 * @GraphQLField(
14
 *   id = "json_path_url",
15
 *   name = "pathToUrl",
16
 *   secure = true,
17
 *   type = "Url",
18
 *   parents = {"JsonObject", "JsonList"},
19
 *   arguments={
20
 *     "steps" = {
21
 *       "type" = "String",
22
 *       "multi" = true
23
 *     }
24
 *   }
25
 * )
26
 */
27
class JsonPathToUrl extends Route {
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function resolve($value, array $args, ResolveContext $context, ResolveInfo $info) {
33
    foreach (parent::resolveValues(NULL, ['path' => NestedArray::getValue($value, $args['steps'])], $context, $info) as $item) {
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (resolveValues() instead of resolve()). Are you sure this is correct? If so, you might want to change this to $this->resolveValues().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
34
      return $item;
35
    }
36
  }
37
38
}
39