@@ -44,28 +44,27 @@ protected function generateFromPsr7Request(Psr7Request $request) : string
44
44
$ timestamp = isset ($ this ->request ->getHeader ('X-SIGNED-TIMESTAMP ' )[0 ]) ?
45
45
$ this ->request ->getHeader ('X-SIGNED-TIMESTAMP ' )[0 ] : '' ;
46
46
47
- $ string = json_decode ((string ) $ this ->request ->getBody ());
47
+ $ payload = [
48
+ 'id ' => (string ) $ id ,
49
+ 'method ' => strtoupper ($ this ->request ->getMethod ()),
50
+ 'timestamp ' => $ timestamp ,
51
+ 'uri ' => rtrim ((string ) $ this ->request ->getUri (), '/ ' )
52
+ ];
48
53
49
- if (is_null ($ string )) {
50
- return json_encode ([
51
- 'id ' => (string )$ id ,
52
- 'method ' => strtoupper ($ this ->request ->getMethod ()),
53
- 'timestamp ' => $ timestamp ,
54
- 'uri ' => rtrim ((string )$ this ->request ->getUri (), '/ ' ),
54
+ if (is_null (json_decode ((string ) $ this ->request ->getBody ()))) {
55
+ $ payload = array_merge ($ payload , [
55
56
'content ' => (string ) $ this ->request ->getBody ()
56
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
57
+ ]);
58
+ } else {
59
+ $ payload = array_merge ($ payload , [
60
+ 'content ' => json_encode (
61
+ json_decode ((string ) $ this ->request ->getBody ()),
62
+ JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
63
+ )
64
+ ]);
57
65
}
58
66
59
- return json_encode ([
60
- 'id ' => (string ) $ id ,
61
- 'method ' => strtoupper ($ this ->request ->getMethod ()),
62
- 'timestamp ' => $ timestamp ,
63
- 'uri ' => rtrim ((string ) $ this ->request ->getUri (), '/ ' ),
64
- 'content ' => json_encode (
65
- json_decode ((string ) $ this ->request ->getBody ()),
66
- JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
67
- )
68
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
67
+ return json_encode ($ payload , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
69
68
}
70
69
71
70
/**
@@ -82,28 +81,27 @@ protected function generateFromIlluminateRequest(IlluminateRequest $request) : s
82
81
$ id = $ this ->request ->headers ->get ('X-SIGNED-ID ' , '' );
83
82
$ timestamp = $ this ->request ->headers ->get ('X-SIGNED-TIMESTAMP ' , '' );
84
83
85
- $ string = json_decode ((string ) $ this ->request ->getContent ());
84
+ $ payload = [
85
+ 'id ' => (string ) $ id ,
86
+ 'method ' => strtoupper ($ this ->request ->getMethod ()),
87
+ 'timestamp ' => $ timestamp ,
88
+ 'uri ' => rtrim ((string ) $ this ->request ->fullUrl (), '/ ' ),
89
+ ];
86
90
87
- if (is_null ($ string )) {
88
- return json_encode ([
89
- 'id ' => (string ) $ id ,
90
- 'method ' => strtoupper ($ this ->request ->getMethod ()),
91
- 'timestamp ' => $ timestamp ,
92
- 'uri ' => rtrim ((string ) $ this ->request ->fullUrl (), '/ ' ),
91
+ if (is_null (json_decode ((string ) $ this ->request ->getContent ()))) {
92
+ $ payload = array_merge ($ payload , [
93
93
'content ' => (string ) $ this ->request ->getContent ()
94
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
94
+ ]);
95
+ } else {
96
+ $ payload = array_merge ($ payload , [
97
+ 'content ' => json_encode (
98
+ json_decode ((string )$ this ->request ->getContent ()),
99
+ JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
100
+ )
101
+ ]);
95
102
}
96
103
97
- return json_encode ([
98
- 'id ' => (string )$ id ,
99
- 'method ' => strtoupper ($ this ->request ->getMethod ()),
100
- 'timestamp ' => $ timestamp ,
101
- 'uri ' => rtrim ((string ) $ this ->request ->fullUrl (), '/ ' ),
102
- 'content ' => json_encode (
103
- json_decode ((string ) $ this ->request ->getContent ()),
104
- JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
105
- )
106
- ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
104
+ return json_encode ($ payload , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
107
105
}
108
106
109
107
/**
0 commit comments