@@ -201,6 +201,7 @@ private static function getSelectedData(string $json, array $data): string
201201 */
202202 private static function unsetArray (array &$ json , array $ data ): void
203203 {
204+ $ attrsCase = ConfigHelper::getParam (ConfigInterface::ATTRIBUTES_CASE );
204205 foreach ($ json as $ type => &$ jsonObject ) {
205206
206207 if ($ type === ApiInterface::RAML_DATA ) { // unset only data->attributes fields
@@ -211,6 +212,8 @@ private static function unsetArray(array &$json, array $data): void
211212
212213 if (\in_array ($ key , $ data , true ) === false ) {
213214 unset($ v [JSONApiInterface::CONTENT_ATTRIBUTES ][$ key ]);
215+ } else if ($ attrsCase !== ConfigInterface::DEFAULT_CASE ) {
216+ self ::changeParamKey ($ json , $ k , $ v , $ attrsCase );
214217 }
215218 }
216219 }
@@ -236,22 +239,33 @@ private static function unsetObject(array &$json, array $data): void
236239 if (\in_array ($ k , $ data , true ) === false ) {
237240 unset($ json [JSONApiInterface::CONTENT_DATA ][JSONApiInterface::CONTENT_ATTRIBUTES ][$ k ]);
238241 } else if ($ attrsCase !== ConfigInterface::DEFAULT_CASE ) {
239- $ changedKey = $ k ;
240- if ($ attrsCase === ConfigInterface::CAMEL_CASE ) {
241- $ changedKey = self ::changeParamKeyToLowerCamelCase ($ k );
242- } else if ($ attrsCase === ConfigInterface::LISP_CASE ) {
243- $ changedKey = self ::changeParamKeyToLispCase ($ k );
244- }
245-
246- $ json [JSONApiInterface::CONTENT_DATA ][JSONApiInterface::CONTENT_ATTRIBUTES ][$ changedKey ] = $ v ;
247- if ($ changedKey !== $ k ) {
248- unset($ json [JSONApiInterface::CONTENT_DATA ][JSONApiInterface::CONTENT_ATTRIBUTES ][$ k ]);
249- }
242+ self ::changeParamKey ($ json , $ k , $ v , $ attrsCase );
250243 }
251244 }
252245 }
253246 }
254247
248+ /**
249+ * @param array $json
250+ * @param string $k
251+ * @param mixed $v
252+ * @param string $attrsCase
253+ */
254+ public static function changeParamKey (array &$ json , string $ k , $ v , string $ attrsCase ): void
255+ {
256+ $ changedKey = $ k ;
257+ if ($ attrsCase === ConfigInterface::CAMEL_CASE ) {
258+ $ changedKey = self ::changeParamKeyToLowerCamelCase ($ k );
259+ } else if ($ attrsCase === ConfigInterface::LISP_CASE ) {
260+ $ changedKey = self ::changeParamKeyToLispCase ($ k );
261+ }
262+
263+ $ json [JSONApiInterface::CONTENT_DATA ][JSONApiInterface::CONTENT_ATTRIBUTES ][$ changedKey ] = $ v ;
264+ if ($ changedKey !== $ k ) {
265+ unset($ json [JSONApiInterface::CONTENT_DATA ][JSONApiInterface::CONTENT_ATTRIBUTES ][$ k ]);
266+ }
267+ }
268+
255269 /**
256270 * @param string $param
257271 * @return string
0 commit comments