- foreach ( $queue->getAllQueuedJobs() as $job ) {
- $this->output( $job->toString() . " status=unclaimed\n" );
- }
- foreach ( $queue->getAllDelayedJobs() as $job ) {
- $this->output( $job->toString() . " status=delayed\n" );
- }
- foreach ( $queue->getAllAcquiredJobs() as $job ) {
- $this->output( $job->toString() . " status=claimed\n" );
- }
- foreach ( $queue->getAllAbandonedJobs() as $job ) {
- $this->output( $job->toString() . " status=abandoned\n" );
+ foreach ( $filteredStates as $state => $method ) {
+ foreach ( $queue->$method() as $job ) {
+ /** @var Job $job */
+ $this->output( $job->toString() . " status=$state\n" );
+ if ( ++$count >= $stateLimit ) {
+ return;
+ }
+ }