|
@@ -44,8 +44,8 @@ discard block |
|
|
block discarded – undo |
|
44
|
44
|
array $type, |
|
45
|
45
|
SerializationContext $context |
|
46
|
46
|
) { |
|
47
|
|
- if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || (!isset($type['params'][1]) && $enum instanceof \BackedEnum)) { |
|
48
|
|
- if (!$enum instanceof \BackedEnum) { |
|
|
47
|
+ if ((isset($type['params'][1]) && 'value' === $type['params'][1]) || ( ! isset($type['params'][1]) && $enum instanceof \BackedEnum)) { |
|
|
48
|
+ if ( ! $enum instanceof \BackedEnum) { |
|
49
|
49
|
throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', get_class($enum))); |
|
50
|
50
|
} |
|
51
|
51
|
|
|
@@ -67,13 +67,13 @@ discard block |
|
|
block discarded – undo |
|
67
|
67
|
$caseValue = (string) $data; |
|
68
|
68
|
|
|
69
|
69
|
$ref = new \ReflectionEnum($enumType); |
|
70
|
|
- if (isset($type['params'][1]) && 'value' === $type['params'][1] || (!isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
71
|
|
- if (!is_a($enumType, \BackedEnum::class, true)) { |
|
|
70
|
+ if (isset($type['params'][1]) && 'value' === $type['params'][1] || ( ! isset($type['params'][1]) && is_a($enumType, \BackedEnum::class, true))) { |
|
|
71
|
+ if ( ! is_a($enumType, \BackedEnum::class, true)) { |
|
72
|
72
|
throw new InvalidMetadataException(sprintf('The type "%s" is not a backed enum, thus you can not use "value" as serialization mode for its value.', $enumType)); |
|
73
|
73
|
} |
|
74
|
74
|
|
|
75
|
75
|
if ('int' === $ref->getBackingType()->getName()) { |
|
76
|
|
- if (!is_numeric($caseValue)) { |
|
|
76
|
+ if ( ! is_numeric($caseValue)) { |
|
77
|
77
|
throw new RuntimeException(sprintf('"%s" is not a valid backing value for enum "%s"', $caseValue, $enumType)); |
|
78
|
78
|
} |
|
79
|
79
|
|
|
@@ -82,7 +82,7 @@ discard block |
|
|
block discarded – undo |
|
82
|
82
|
|
|
83
|
83
|
return $enumType::from($caseValue); |
|
84
|
84
|
} else { |
|
85
|
|
- if (!$ref->hasCase($caseValue)) { |
|
|
85
|
+ if ( ! $ref->hasCase($caseValue)) { |
|
86
|
86
|
throw new InvalidMetadataException(sprintf('The type "%s" does not have the case "%s"', $ref->getName(), $caseValue)); |
|
87
|
87
|
} |
|
88
|
88
|
|