Completed
Pull Request — master (#134)
by Christoffer
02:39
created

BooleanCoercer::coerce()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace Digia\GraphQL\Type\Coercer;
4
5
use Digia\GraphQL\Error\InvalidTypeException;
6
7
class BooleanCoercer extends AbstractCoercer
8
{
9
    /**
10
     * @inheritdoc
11
     */
12
    public function coerce($value)
13
    {
14
        if (!\is_scalar($value)) {
15
            throw new InvalidTypeException(\sprintf('Boolean cannot represent a non-scalar value: %s', $value));
16
        }
17
18
        return (bool)$value;
19
    }
20
}
21