BooleanToStringHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 14 1
A serializeBooleanToString() 0 5 2
A deserializeBooleanToString() 0 7 3
1
<?php
2
3
namespace CCT\Kong\Serializer\Handler;
4
5
use CCT\Kong\Example\BooleanToString;
0 ignored issues
show
Bug introduced by
The type CCT\Kong\Example\BooleanToString 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...
6
use CCT\Kong\Model\Api;
7
use CCT\Kong\Model\BooleanToStringConverter;
0 ignored issues
show
Bug introduced by
The type CCT\Kong\Model\BooleanToStringConverter 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...
8
use JMS\Serializer\Context;
9
use JMS\Serializer\GraphNavigator;
10
use JMS\Serializer\Handler\SubscribingHandlerInterface;
11
use JMS\Serializer\JsonDeserializationVisitor;
12
use JMS\Serializer\JsonSerializationVisitor;
13
use JMS\Serializer\Metadata\StaticPropertyMetadata;
14
use JMS\Serializer\VisitorInterface;
15
use Metadata\PropertyMetadata;
16
use Symfony\Component\PropertyAccess\PropertyAccess;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\PropertyAccess\PropertyAccess 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...
17
18
class BooleanToStringHandler implements SubscribingHandlerInterface
19
{
20 42
    public static function getSubscribingMethods()
21
    {
22
        return [
23
            [
24 42
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
25 42
                'format' => 'json',
26 42
                'type' => 'boolean_string',
27 42
                'method' => 'serializeBooleanToString',
28
            ],
29
            [
30 42
                'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
31 42
                'format' => 'json',
32 42
                'type' => 'boolean_string',
33 42
                'method' => 'deserializeBooleanToString',
34
            ],
35
        ];
36
    }
37
38 4
    public function serializeBooleanToString(JsonSerializationVisitor $visitor, $value, array $type, Context $context)
0 ignored issues
show
Unused Code introduced by
The parameter $visitor is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    public function serializeBooleanToString(/** @scrutinizer ignore-unused */ JsonSerializationVisitor $visitor, $value, array $type, Context $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    public function serializeBooleanToString(JsonSerializationVisitor $visitor, $value, array $type, /** @scrutinizer ignore-unused */ Context $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    public function serializeBooleanToString(JsonSerializationVisitor $visitor, $value, /** @scrutinizer ignore-unused */ array $type, Context $context)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40 4
        return (true === $value)
41 4
            ? 'true'
42 4
            : 'false'
43
        ;
44
    }
45
46 7
    public function deserializeBooleanToString(JsonDeserializationVisitor $visitor, $value, array $type, Context $context)
47
    {
48 7
        if ($value === 'false' || $value === '0') {
49
            $value = false;
50
        }
51
52 7
        return $visitor->visitBoolean($value, $type, $context);
53
    }
54
}