BooleanType::coerceLiteral()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Fubhy\GraphQL\Type\Definition\Types\Scalars;
4
5
use Fubhy\GraphQL\Language\Node;
6
use Fubhy\GraphQL\Language\Node\BooleanValue;
7
use Fubhy\GraphQL\Type\Definition\Types\ScalarType;
8
9
class BooleanType extends ScalarType
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name = 'Boolean';
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 45
    public function coerce($value)
20
    {
21 45
        return (bool) $value;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 24
    public function coerceLiteral(Node $node)
28
    {
29 24
        return $node instanceof BooleanValue ? $node->get('value') : NULL;
30
    }
31
}
32