ToBoolean   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 8 2
A extract() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\ORM\GraphQL\Hydrator\Strategy;
6
7
use Laminas\Hydrator\Strategy\StrategyInterface;
8
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Transform a value into a php native boolean
12
 *
13
 * @returns float
14
 */
15
class ToBoolean extends Collection implements
16
    StrategyInterface
17
{
18
    #[Override]
19
    public function extract(mixed $value, object|null $object = null): bool|null
20
    {
21
        if ($value === null) {
22
            // @codeCoverageIgnoreStart
23
            return $value;
24
            // @codeCoverageIgnoreEnd
25
        }
26
27
        return (bool) $value;
28
    }
29
30
    /**
31
     * @param mixed[]|null $data
32
     *
33
     * @codeCoverageIgnore
34
     */
35
    #[Override]
36
    public function hydrate(mixed $value, array|null $data): bool|null
37
    {
38
        if ($value === null) {
39
            return $value;
40
        }
41
42
        return (bool) $value;
43
    }
44
}
45