Completed
Pull Request — 8.x-3.x (#525)
by Sebastian
04:20 queued 01:58
created

ScalarPluginBase::parseValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql\Plugin\GraphQL\Scalars;
4
5
use Drupal\Component\Plugin\PluginBase;
6
use Drupal\graphql\Plugin\GraphQL\PluggableSchemaBuilder;
7
use Drupal\graphql\Plugin\GraphQL\Traits\CacheablePluginTrait;
8
use Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface;
9
use GraphQL\Type\Definition\CustomScalarType;
10
11
abstract class ScalarPluginBase extends PluginBase implements TypeSystemPluginInterface {
12
  use CacheablePluginTrait;
13
14
  /**
15
   * {@inheritdoc}
16
   */
17
  public static function createInstance(PluggableSchemaBuilder $builder, $definition, $id) {
18
    $callable = ['GraphQL\Type\Definition\Type', strtolower($definition['name'])];
19
    if (is_callable($callable)) {
20
      return $callable();
21
    }
22
23
    return new CustomScalarType([
24
25
    ] + $definition);
26
  }
27
28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function getDefinition() {
32
    return $this->getPluginDefinition();
33
  }
34
35
  /**
36
   * @param mixed $value
37
   */
38
  public static function serialize($value) {
39
    throw new \LogicException('Missing method.');
40
  }
41
42
  /**
43
   * @param mixed $value
44
   *
45
   * @return mixed
46
   */
47
  public static function parseValue($value) {
48
    throw new \LogicException('Missing method.');
49
  }
50
51
  /**
52
   * @param mixed $node
53
   *
54
   * @return mixed
55
   */
56
  public static function parseLiteral($node) {
57
    throw new \LogicException('Missing method.');
58
  }
59
60
}
61