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

AnyType::parseLiteral()   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\Error\Error;
14
use GraphQL\Type\Definition\ScalarType;
15
16
class AnyType extends ScalarType
17
{
18
    public const ANY = 'Any';
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function __construct(array $config = [])
24
    {
25
        $this->name = self::ANY;
26
        $this->description = 'The `Any` type can represent different type of scalars like string, integer, boolean etc.';
27
28
        parent::__construct($config);
29
    }
30
31
    /**
32
     * Serializes an internal value to include in a response.
33
     *
34
     * @param string $value
35
     *
36
     * @return string
37
     */
38
    public function serialize($value)
39
    {
40
        return $value;
41
    }
42
43
    /**
44
     * Parses an externally provided value (query variable) to use as an input
45
     *
46
     * @param mixed $value
47
     *
48
     * @return mixed
49
     *
50
     * @throws Error
51
     */
52
    public function parseValue($value)
53
    {
54
        return $value;
55
    }
56
57
    /**
58
     * @param \GraphQL\Language\AST\Node $valueNode
59
     *
60
     * @return string
61
     *
62
     * @throws Error
63
     */
64
    public function parseLiteral($valueNode)
65
    {
66
        return $valueNode->value;
67
    }
68
}
69