@@ -129,25 +129,24 @@ public function getStatusCounters(): array
129129 }
130130 }
131131 }
132-
132+
133133 foreach ($ this ->cache ->getAll () as $ resourceType => $ resources ) {
134- foreach ($ resources as $ resourceId => $ resource ) {
134+ foreach ($ resources as $ resource ) {
135135 if ($ resourceType === Resource::TYPE_DOCUMENT && is_string ($ resource )) {
136136 $ documentStatus = $ resource ;
137137 $ status [$ resourceType ][$ documentStatus ]++;
138-
139- if ($ documentStatus === ' pending ' && $ status [$ resourceType ]['pending ' ] > 0 ) {
138+
139+ if ($ status [$ resourceType ]['pending ' ] > 0 ) {
140140 $ status [$ resourceType ]['pending ' ]--;
141141 }
142-
143- continue ; // Skip to next iteration
142+
143+ continue ;
144144 }
145-
146- // For all other non-document resources
145+
147146 if (isset ($ status [$ resource ->getName ()])) {
148147 $ status [$ resource ->getName ()][$ resource ->getStatus ()]++;
149-
150- if ($ resource -> getStatus () === ' pending ' && $ status [$ resource ->getName ()]['pending ' ] > 0 ) {
148+
149+ if ($ status [$ resource ->getName ()]['pending ' ] > 0 ) {
151150 $ status [$ resource ->getName ()]['pending ' ]--;
152151 }
153152 }
@@ -270,46 +269,46 @@ public function getCurrentResource(): string
270269 * @param string $statusLevel If no status level is provided, all status types will be returned.
271270 * @return array<array<string, mixed>>
272271 */
273- public function getReport (string $ statusLevel = '' ): array
274- {
275- $ report = [];
276- $ cache = $ this ->cache ->getAll ();
272+ public function getReport (string $ statusLevel = '' ): array
273+ {
274+ $ report = [];
275+ $ cache = $ this ->cache ->getAll ();
276+
277+ foreach ($ cache as $ type => $ resources ) {
278+ foreach ($ resources as $ id => $ resource ) {
279+ if ($ type === Resource::TYPE_DOCUMENT && is_string ($ resource )) {
280+ if ($ statusLevel && $ resource !== $ statusLevel ) {
281+ continue ;
282+ }
283+ // no message for document is stored
284+ $ report [] = [
285+ 'resource ' => $ type ,
286+ 'id ' => $ id ,
287+ 'status ' => $ resource ,
288+ 'message ' => '' ,
289+ ];
290+ continue ;
291+ }
292+
293+ if (!is_object ($ resource )) {
294+ continue ;
295+ }
277296
278- foreach ($ cache as $ type => $ resources ) {
279- foreach ($ resources as $ id => $ resource ) {
280- if ($ type === Resource::TYPE_DOCUMENT && is_string ($ resource )) {
281- if ($ statusLevel && $ resource !== $ statusLevel ) {
297+ if ($ statusLevel && $ resource ->getStatus () !== $ statusLevel ) {
282298 continue ;
283299 }
284- // no message for document is stored
300+
285301 $ report [] = [
286302 'resource ' => $ type ,
287- 'id ' => $ id ,
288- 'status ' => $ resource ,
289- 'message ' => '' ,
303+ 'id ' => $ resource -> getId () ,
304+ 'status ' => $ resource-> getStatus () ,
305+ 'message ' => $ resource -> getMessage () ,
290306 ];
291- continue ;
292- }
293-
294- if (!is_object ($ resource )) {
295- continue ;
296- }
297-
298- if ($ statusLevel && $ resource ->getStatus () !== $ statusLevel ) {
299- continue ;
300307 }
301-
302- $ report [] = [
303- 'resource ' => $ type ,
304- 'id ' => $ resource ->getId (),
305- 'status ' => $ resource ->getStatus (),
306- 'message ' => $ resource ->getMessage (),
307- ];
308308 }
309- }
310309
311- return $ report ;
312- }
310+ return $ report ;
311+ }
313312
314313 /**
315314 * @throws \Exception
0 commit comments