Completed
Push — 8.x-3.x ( e67c0e...2e01b0 )
by Philipp
02:27
created

EnumPluginBase::getDefinition()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql\Plugin\GraphQL\Enums;
4
5
use Drupal\Component\Plugin\PluginBase;
6
use Drupal\graphql\GraphQL\Type\EnumType;
7
use Drupal\graphql\Plugin\GraphQL\PluggableSchemaBuilderInterface;
8
use Drupal\graphql\Plugin\GraphQL\Traits\CacheablePluginTrait;
9
use Drupal\graphql\Plugin\GraphQL\Traits\NamedPluginTrait;
10
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface;
11
12
/**
13
 * Base class for enum plugins.
14
 */
15 View Code Duplication
abstract class EnumPluginBase extends PluginBase implements TypeSystemPluginInterface {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
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