BooleanType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A coerce() 0 4 1
A coerceLiteral() 0 4 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