XMLName::resolveValues()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
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\Plugin\GraphQL\Fields\FieldPluginBase;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
/**
10
 * Get an xml elements tag name.
11
 *
12
 * @GraphQLField(
13
 *   id = "xml_name",
14
 *   secure = true,
15
 *   type = "String",
16
 *   name = "name",
17
 *   parents = { "XMLElement" }
18
 * )
19
 */
20
class XMLName extends FieldPluginBase {
21
22
  /**
23
   * {@inheritdoc}
24
   */
25
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
26
    if ($value instanceof \DOMElement) {
27
      yield $value->tagName;
28
    }
29
  }
30
31
}
32