Code Duplication    Length = 17-20 lines in 2 locations

modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/Config/ConfigEntityProperty.php 1 location

@@ 18-34 (lines=17) @@
15
 *   deriver = "Drupal\graphql_core\Plugin\Deriver\Fields\ConfigEntityPropertyDeriver",
16
 * )
17
 */
18
class ConfigEntityProperty extends EntityFieldBase {
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function resolveValues($value, array $args, ResolveInfo $info) {
24
    $definition = $this->getPluginDefinition();
25
    $property = $definition['property'];
26
    $result = $value->get($property);
27
    if (($type = $info->getReturnType()->getNamedType()) && $type instanceof AbstractScalarType) {
28
      $result = $type->serialize($result);
29
    }
30
31
    yield $result;
32
  }
33
34
}
35

modules/graphql_core/src/Plugin/GraphQL/Fields/EntityFieldBase.php 1 location

@@ 13-32 (lines=20) @@
10
/**
11
 * Base class for entity field plugins.
12
 */
13
class EntityFieldBase extends FieldPluginBase {
14
15
  /**
16
   * {@inheritdoc}
17
   */
18
  protected function resolveItem($item, array $args, ResolveInfo $info) {
19
    if ($item instanceof FieldItemInterface) {
20
      $definition = $this->getPluginDefinition();
21
      $property = $definition['property'];
22
      $result = $item->get($property)->getValue();
23
24
      if (($type = $info->getReturnType()->getNamedType()) && $type instanceof AbstractScalarType) {
25
        $result = $type->serialize($result);
26
      }
27
28
      return $result;
29
    }
30
  }
31
32
}
33