XPathToUrl::resolve()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 4
1
<?php
2
3
namespace Drupal\graphql_xml\Plugin\GraphQL\Fields;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql_core\Plugin\GraphQL\Fields\Routing\Route;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
/**
10
 * Extract Url objects from xpath values.
11
 *
12
 * @GraphQLField(
13
 *   id = "xml_xpath_url",
14
 *   name = "xpathToUrl",
15
 *   secure = true,
16
 *   type = "Url",
17
 *   parents = {"XMLElement"},
18
 *   multi = true,
19
 *   arguments = {
20
 *     "query" = "String"
21
 *   }
22
 * )
23
 */
24
class XPathToUrl extends Route {
25
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function resolve($value, array $args, ResolveContext $context, ResolveInfo $info) {
30
    if ($value instanceof \DOMElement) {
31
      $xpath = new \DOMXPath($value->ownerDocument);
32
      foreach ($xpath->query($args['query'], $value) as $el) {
33
        /** @var $el \DOMElement */
34
        $iterator = parent::resolveValues(NULL, ['path' => $el->textContent], $context, $info);
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...
35
        return iterator_to_array($iterator);
36
      }
37
    }
38
  }
39
40
}
41