XMLAttribute   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 5 2
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 attribute value.
11
 *
12
 * @GraphQLField(
13
 *   id = "xml_attribute",
14
 *   secure = true,
15
 *   type = "String",
16
 *   name = "attribute",
17
 *   arguments = { "name": "String" },
18
 *   parents = { "XMLElement" }
19
 * )
20
 */
21
class XMLAttribute extends FieldPluginBase {
22
23
  /**
24
   * {@inheritdoc}
25
   */
26
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
27
    if ($value instanceof \DOMElement) {
28
      yield $value->getAttribute($args['name']);
29
    }
30
  }
31
32
}
33