Completed
Push — master ( 638b8d...de83b5 )
by John
01:47 queued 17s
created

BoolProcessor::hydrate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Hydrator package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\PhpApi\Hydrator\Processors\Scalar;
10
11
/**
12
 * @author John Kleijn <[email protected]>
13
 */
14
class BoolProcessor extends ScalarProcessor
15
{
16
    /**
17
     * Cast a scalar value using the schema.
18
     *
19
     * @param mixed $value
20
     *
21
     * @return bool
22
     */
23
    public function hydrate($value)
24
    {
25
        if ($value === null) {
26
            return $this->schema->getDefault();
27
        }
28
29
        return (bool)$value;
30
    }
31
}
32