File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
12
12
### Changed
13
13
14
+ ## [ 1.3.1]
15
+
16
+ ### Added
17
+
18
+ ### Changed
19
+ - fix(serialization): Float serialization also accepts integer values. [ #85 ] ( https://github.com/microsoft/kiota-serialization-json-php/pull/85 )
20
+
14
21
## [ 1.3.0]
15
22
16
23
### Added
Original file line number Diff line number Diff line change @@ -74,7 +74,13 @@ public function getIntegerValue(): ?int {
74
74
* @inheritDoc
75
75
*/
76
76
public function getFloatValue (): ?float {
77
- return is_float ($ this ->jsonNode ) ? $ this ->jsonNode : null ;
77
+ if (is_float ($ this ->jsonNode )) {
78
+ return $ this ->jsonNode ;
79
+ }
80
+ if (is_int ($ this ->jsonNode )) {
81
+ return floatval ($ this ->jsonNode );
82
+ }
83
+ return null ;
78
84
}
79
85
80
86
/**
Original file line number Diff line number Diff line change @@ -62,12 +62,18 @@ public function testGetObjectValue(): void {
62
62
$ this ->assertEquals (123.122 , $ expected ->getHeight ());
63
63
}
64
64
65
- public function testGetFloatValue (): void {
65
+ public function testGetFloatValueWithFloat (): void {
66
66
$ this ->parseNode = new JsonParseNode (1243.12 );
67
67
$ expected = $ this ->parseNode ->getFloatValue ();
68
68
$ this ->assertEquals (1243.12 , $ expected );
69
69
}
70
70
71
+ public function testGetFloatValueWithInt (): void {
72
+ $ this ->parseNode = new JsonParseNode (1243 );
73
+ $ expected = $ this ->parseNode ->getFloatValue ();
74
+ $ this ->assertEquals (1243.00 , $ expected );
75
+ }
76
+
71
77
/**
72
78
* @throws Exception
73
79
*/
You can’t perform that action at this time.
0 commit comments