Code Duplication    Length = 29-32 lines in 2 locations

src/Plugin/GraphQL/Enums/EnumPluginBase.php 1 location

@@ 15-46 (lines=32) @@
12
/**
13
 * Base class for enum plugins.
14
 */
15
abstract class EnumPluginBase extends PluginBase implements TypeSystemPluginInterface {
16
  use NamedPluginTrait;
17
  use CacheablePluginTrait;
18
19
  /**
20
   * The type instance.
21
   *
22
   * @var \Drupal\graphql\GraphQL\Type\EnumType
23
   */
24
  protected $definition;
25
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function getDefinition(PluggableSchemaBuilderInterface $schemaBuilder) {
30
    if (!isset($this->definition)) {
31
      $this->definition = new EnumType($this, [
32
        'name' => $this->buildName(),
33
        'description' => $this->buildDescription(),
34
        'values' => $this->buildValues($schemaBuilder),
35
      ]);
36
    }
37
38
    return $this->definition;
39
  }
40
41
  /**
42
   * {@inheritdoc}
43
   */
44
  abstract public function buildValues(PluggableSchemaBuilderInterface $schemaManager);
45
46
}
47

src/Plugin/GraphQL/Interfaces/InterfacePluginBase.php 1 location

@@ 16-44 (lines=29) @@
13
/**
14
 * Base class for GraphQL interface plugins.
15
 */
16
abstract class InterfacePluginBase extends PluginBase implements TypeSystemPluginInterface {
17
  use CacheablePluginTrait;
18
  use NamedPluginTrait;
19
  use FieldablePluginTrait;
20
21
  /**
22
   * The type instance.
23
   *
24
   * @var \Drupal\graphql\GraphQL\Type\InterfaceType
25
   */
26
  protected $definition;
27
28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function getDefinition(PluggableSchemaBuilderInterface $schemaBuilder) {
32
    if (!isset($this->definition)) {
33
      $this->definition = new InterfaceType($this, [
34
        'name' => $this->buildName(),
35
        'description' => $this->buildDescription(),
36
      ]);
37
38
      $this->definition->addFields($this->buildFields($schemaBuilder));
39
    }
40
41
    return $this->definition;
42
  }
43
44
}
45