Failed Conditions
Push — master ( 9327e7...7f99bf )
by Vladimir
04:21
created

ComplexScalar   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 12
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A parseValue() 0 7 2
A parseLiteral() 0 7 2
A serialize() 0 7 2
A create() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Tests\Executor\TestClasses;
6
7
use GraphQL\Error\Error;
8
use GraphQL\Type\Definition\ScalarType;
9
use GraphQL\Utils\Utils;
10
11
class ComplexScalar extends ScalarType
12
{
13
    /** @var string */
14
    public $name = 'ComplexScalar';
15
16
    public static function create() : self
17
    {
18
        return new self();
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function serialize($value)
25
    {
26
        if ($value === 'DeserializedValue') {
27
            return 'SerializedValue';
28
        }
29
30
        throw new Error('Cannot serialize value as ComplexScalar: ' . Utils::printSafe($value));
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function parseValue($value)
37
    {
38
        if ($value === 'SerializedValue') {
39
            return 'DeserializedValue';
40
        }
41
42
        throw new Error('Cannot represent value as ComplexScalar: ' . Utils::printSafe($value));
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function parseLiteral($valueNode, ?array $variables = null)
49
    {
50
        if ($valueNode->value === 'SerializedValue') {
51
            return 'DeserializedValue';
52
        }
53
54
        throw new Error('Cannot represent literal as ComplexScalar: ' . Utils::printSafe($valueNode->value));
55
    }
56
}
57