BoolProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 8 2
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