XMLResponseContent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 8 2
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\Response\ResponseContent;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
/**
10
 * Get the response content of an internal or external request as xml document.
11
 *
12
 * @GraphQLField(
13
 *   id = "xml_response_content",
14
 *   secure = true,
15
 *   name = "xml",
16
 *   type = "XMLElement",
17
 *   parents = {"InternalResponse", "ExternalResponse"}
18
 * )
19
 */
20
class XMLResponseContent extends ResponseContent {
21
22
  /**
23
   * {@inheritdoc}
24
   */
25
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
26
    foreach (parent::resolveValues($value, $args, $context, $info) as $item) {
27
      $document = new \DOMDocument();
28
      libxml_use_internal_errors(TRUE);
29
      $document->loadXML($item);
30
      yield $document->documentElement;
31
    }
32
  }
33
34
}
35