Completed
Push — master ( ce0ced...50615c )
by Alexandr
02:46
created

IdType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 4 1
A isValidValue() 0 4 1
A getDescription() 0 8 1
1
<?php
2
/*
3
* This file is a part of GraphQL project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 12/4/15 12:41 AM
7
*/
8
9
namespace Youshido\GraphQL\Type\Scalar;
10
11
12
class IdType extends AbstractScalarType
13
{
14
    public function serialize($value)
15
    {
16
        return (string)$value;
17
    }
18
19
    public function isValidValue($value)
20
    {
21
        return !empty($value);
22
    }
23
24
    public function getDescription()
25
    {
26
        return 'The `ID` scalar type represents a unique identifier, often used to ' .
27
               'refetch an object or as key for a cache. The ID type appears in a JSON ' .
28
               'response as a String; however, it is not intended to be human-readable. ' .
29
               'When expected as an input type, any string (such as `"4"`) or integer ' .
30
               '(such as `4`) input value will be accepted as an ID.';
31
    }
32
}