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

UndefinedType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A serialize() 0 11 4
1
<?php
2
3
namespace Drupal\graphql\GraphQL\Type;
4
5
use Youshido\GraphQL\Type\Scalar\AbstractScalarType;
6
7
class UndefinedType extends AbstractScalarType {
8
9
  /**
10
   * {@inheritdoc}
11
   */
12
  public function getName() {
13
    return 'Undefined';
14
  }
15
16
  /**
17
   * {@inheritdoc}
18
   */
19
  public function serialize($value) {
20
    if (is_scalar($value)) {
21
      return (string) $value;
22
    }
23
24
    if (is_object($value) || is_array($value)) {
25
      return json_encode($value);
26
    }
27
28
    return '';
29
  }
30
}
31