Key::resolveValues()   A
last analyzed

Complexity

Conditions 6
Paths 4

Size

Total Lines 8

Duplication

Lines 3
Ratio 37.5 %

Importance

Changes 0
Metric Value
dl 3
loc 8
rs 9.2222
c 0
b 0
f 0
cc 6
nc 4
nop 4
1
<?php
2
3
namespace Drupal\graphql_metatag\Plugin\GraphQL\Fields\Metatag;
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
 * @GraphQLField(
11
 *   secure = true,
12
 *   id = "metatag_key",
13
 *   name = "key",
14
 *   type = "String",
15
 *   parents = {"Metatag"}
16
 * )
17
 */
18
class Key extends FieldPluginBase {
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
24
    if (isset($value['#tag']) && $value['#tag'] === 'meta') {
25
      yield isset($value['#attributes']['property']) ? $value['#attributes']['property'] : $value['#attributes']['name'];
26
    }
27 View Code Duplication
    else if (isset($value['#tag']) && $value['#tag'] === 'link') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
      yield $value['#attributes']['rel'];
29
    }
30
  }
31
32
}
33