File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,17 +112,15 @@ final public function getItems(): array
112112 */
113113 final public function jsonSerialize (): array
114114 {
115- $ items = [];
116- foreach ($ this ->items as $ item ) {
117- $ items [] = $ item ->jsonSerialize ();
118- }
119-
120115 return [
121116 'offset ' => $ this ->offset ,
122117 'limit ' => $ this ->limit ,
123118 'filters ' => $ this ->filters ,
124119 'sort ' => $ this ->sort ,
125- 'items ' => $ items ,
120+ 'items ' => array_map (
121+ static fn (ModelInterface $ model ) => $ model ->jsonSerialize (),
122+ $ this ->items
123+ ),
126124 'count ' => $ this ->count ,
127125 ];
128126 }
Original file line number Diff line number Diff line change @@ -62,17 +62,15 @@ abstract class AbstractCollectionResponse implements CollectionResponseInterface
6262 */
6363 final public function jsonSerialize (): array
6464 {
65- $ items = [];
66- foreach ($ this ->items as $ item ) {
67- $ items [] = $ item ->jsonSerialize ();
68- }
69-
7065 return [
7166 'offset ' => $ this ->offset ,
7267 'limit ' => $ this ->limit ,
7368 'filters ' => $ this ->getFilters ()->jsonSerialize (),
7469 'sort ' => $ this ->getSort ()->jsonSerialize (),
75- 'items ' => $ items ,
70+ 'items ' => array_map (
71+ static fn (ModelResponseInterface $ modelResponse ) => $ modelResponse ->jsonSerialize (),
72+ $ this ->items
73+ ),
7674 'count ' => $ this ->count ,
7775 '_type ' => $ this ->_type ,
7876 '_links ' => $ this ->_links ,
You can’t perform that action at this time.
0 commit comments