@@ -43,62 +43,26 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
4343
4444 $ statement [$ key ] = $ t ->recursiveToArray ($ value );
4545 }
46-
47- if (isset ($ summary ['result ' ]) && method_exists ($ summary ['result ' ], 'getStatement ' )) {
48- /** @var object $result */
49- $ result = $ summary ['result ' ];
50- if (method_exists ($ result , 'getStatement ' )) {
51- $ resultStatement = $ result ->getStatement ();
52- $ statement ['statement ' ] = $ t ->recursiveToArray ($ resultStatement );
53- if (is_object ($ resultStatement ) && method_exists ($ resultStatement , 'getParameters ' )) {
54- $ params = $ resultStatement ->getParameters ();
55- $ statement ['parameters ' ] = is_array ($ params )
56- ? $ params
57- : $ t ->recursiveToArray ($ params );
58- }
59- }
60- }
6146 $ successfulStatements [] = $ statement ;
6247 }
6348
6449 $ failedStatements = array_map (
65- function (array $ x ) use ($ t ) {
66- $ statement = [
67- 'status ' => 'failure ' ,
68- 'time ' => $ x ['time ' ],
69- 'timestamp ' => $ x ['timestamp ' ],
70- 'result ' => [
71- 'statement ' => $ x ['statement ' ]?->toArray(),
72- ],
73- 'exception ' => [
74- 'code ' => $ x ['exception ' ]->getErrors ()[0 ]->getCode (),
75- 'message ' => $ x ['exception ' ]->getErrors ()[0 ]->getMessage (),
76- 'classification ' => $ x ['exception ' ]->getErrors ()[0 ]->getClassification (),
77- 'category ' => $ x ['exception ' ]->getErrors ()[0 ]->getCategory (),
78- 'title ' => $ x ['exception ' ]->getErrors ()[0 ]->getTitle (),
79- ],
80- 'error ' => [
81- 'code ' => $ x ['exception ' ]->getErrors ()[0 ]->getCode (),
82- 'message ' => $ x ['exception ' ]->getErrors ()[0 ]->getMessage (),
83- 'classification ' => $ x ['exception ' ]->getErrors ()[0 ]->getClassification (),
84- 'category ' => $ x ['exception ' ]->getErrors ()[0 ]->getCategory (),
85- 'title ' => $ x ['exception ' ]->getErrors ()[0 ]->getTitle (),
86- ],
87- 'alias ' => $ x ['alias ' ],
88- ];
89-
90- if (null !== $ x ['statement ' ]) {
91- $ statement ['statement ' ] = $ t ->recursiveToArray ($ x ['statement ' ]);
92- if (is_object ($ x ['statement ' ]) && method_exists ($ x ['statement ' ], 'getParameters ' )) {
93- $ params = $ x ['statement ' ]->getParameters ();
94- $ statement ['parameters ' ] = is_array ($ params )
95- ? $ params
96- : $ t ->recursiveToArray ($ params );
97- }
98- }
99-
100- return $ statement ;
101- },
50+ static fn (array $ x ) => [
51+ 'status ' => 'failure ' ,
52+ 'time ' => $ x ['time ' ],
53+ 'timestamp ' => $ x ['timestamp ' ],
54+ 'result ' => [
55+ 'statement ' => $ x ['statement ' ]?->toArray(),
56+ ],
57+ 'exception ' => [
58+ 'code ' => $ x ['exception ' ]->getErrors ()[0 ]->getCode (),
59+ 'message ' => $ x ['exception ' ]->getErrors ()[0 ]->getMessage (),
60+ 'classification ' => $ x ['exception ' ]->getErrors ()[0 ]->getClassification (),
61+ 'category ' => $ x ['exception ' ]->getErrors ()[0 ]->getCategory (),
62+ 'title ' => $ x ['exception ' ]->getErrors ()[0 ]->getTitle (),
63+ ],
64+ 'alias ' => $ x ['alias ' ],
65+ ],
10266 $ this ->subscriber ->getProfiledFailures ()
10367 );
10468
@@ -133,18 +97,18 @@ public function getStatements(): array
13397
13498 public function getSuccessfulStatements (): array
13599 {
136- return array_values ( array_filter (
100+ return array_filter (
137101 $ this ->data ['statements ' ],
138102 static fn (array $ x ) => 'success ' === $ x ['status ' ]
139- )) ;
103+ );
140104 }
141105
142106 public function getFailedStatements (): array
143107 {
144- return array_values ( array_filter (
108+ return array_filter (
145109 $ this ->data ['statements ' ],
146110 static fn (array $ x ) => 'failure ' === $ x ['status ' ]
147- )) ;
111+ );
148112 }
149113
150114 /** @api */
@@ -174,7 +138,7 @@ private function recursiveToArray(array|object $obj): mixed
174138 {
175139 if (is_array ($ obj )) {
176140 return array_map (
177- fn (mixed $ x ): mixed => is_array ( $ x ) || is_object ( $ x ) ? $ this ->recursiveToArray ($ x ) : $ x ,
141+ fn (mixed $ x ): mixed => $ this ->recursiveToArray ($ x ),
178142 $ obj
179143 );
180144 }
0 commit comments