Completed
Push — master ( 1615d9...631929 )
by Alexandr
02:52
created

BooleanType::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/27/15 1:22 AM
7
*/
8
9
namespace Youshido\GraphQL\Type\Scalar;
10
11
12
class BooleanType extends AbstractScalarType
13
{
14 7
    public function getName()
15
    {
16 7
        return 'Boolean';
17
    }
18
19 7
    public function serialize($value)
20
    {
21 7
        if ($value === 'true') {
22 1
            return true;
23
        }
24 7
        if ($value === 'false') {
25 1
            return false;
26
        }
27
28 7
        return (bool)$value;
29
    }
30
31 7
    public function isValidValue($value)
32
    {
33 7
        return is_null($value) || is_bool($value);
34
    }
35
36 3
    public function getDescription()
37
    {
38 3
        return 'The `Boolean` scalar type represents `true` or `false`.';
39
    }
40
41
}
42