Completed
Pull Request — 8.x-3.x (#442)
by Sebastian
02:26
created

ObjectType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 3 1
A applies() 0 3 1
A build() 0 3 1
1
<?php
2
3
namespace Drupal\graphql\GraphQL\Type;
4
5
use Drupal\graphql\Plugin\GraphQL\Types\TypePluginBase;
6
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginReferenceInterface;
7
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginReferenceTrait;
8
use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
9
use Youshido\GraphQL\Type\Object\AbstractObjectType;
10
11
class ObjectType extends AbstractObjectType implements TypeSystemPluginReferenceInterface {
12
  use TypeSystemPluginReferenceTrait;
13
14
  /**
15
   * The associated type system plugin.
16
   *
17
   * @var \Drupal\graphql\Plugin\GraphQL\Types\TypePluginBase
18
   */
19
  protected $plugin;
20
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function __construct(TypePluginBase $plugin, array $config = []) {
25
    $this->plugin = $plugin;
26
    $this->config = new ObjectTypeConfig($config, $this, TRUE);
27
  }
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function getName() {
33
    return $this->getConfigValue('name');
34
  }
35
36
  /**
37
   * Checks whether this type applies to a given object.
38
   *
39
   * @param mixed $object
40
   *   The object to check against.
41
   *
42
   * @return bool
43
   *   TRUE if this type applies to the given object, FALSE otherwise.
44
   */
45
  public function applies($object) {
46
    return $this->plugin->applies($object);
47
  }
48
49
  /**
50
   * {@inheritdoc}
51
   */
52
  public function build($config) {
53
    // Nothing to do here.
54
  }
55
56
}
57