|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CCT\Kong\Serializer\Handler; |
|
4
|
|
|
|
|
5
|
|
|
use CCT\Kong\Example\BooleanToString; |
|
|
|
|
|
|
6
|
|
|
use CCT\Kong\Model\Api; |
|
7
|
|
|
use CCT\Kong\Model\BooleanToStringConverter; |
|
|
|
|
|
|
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; |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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
|
|
|
} |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths