Completed
Push — master ( 835ad1...393c4d )
by Rafael
04:39
created

DynamicObjectType::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Type;
12
13
use GraphQL\Type\Definition\ScalarType;
14
15
class DynamicObjectType extends ScalarType
16
{
17
    public const DYNAMIC_OBJECT = 'DynamicObject';
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function __construct()
22
    {
23
        $this->name = self::DYNAMIC_OBJECT;
24
        $this->description = 'The `DynamicObject` represent a object with unknown and dynamic properties. 
25
For this type of objects you can\'t select the properties to get. 
26
27
A common usage of these type of objects is when the object represent a set of **key:value** pairs';
28
29
        parent::__construct([]);
30
    }
31
32
    /**
33
     * Serializes an internal value to include in a response.
34
     *
35
     * @param string $value
36
     *
37
     * @return string
38
     */
39
    public function serialize($value)
40
    {
41
        return $value;
42
    }
43
44
    /**
45
     * Parses an externally provided value (query variable) to use as an input
46
     *
47
     * @param mixed $value
48
     *
49
     * @return mixed
50
     *
51
     * @throws \Error
52
     */
53
    public function parseValue($value)
54
    {
55
        return $value;
56
    }
57
58
    /**
59
     * @param \GraphQL\Language\AST\Node $valueNode
60
     *
61
     * @return string
62
     *
63
     * @throws \Error
64
     */
65
    public function parseLiteral($valueNode)
66
    {
67
        return $valueNode->value;
68
    }
69
}