master

laravel/framework

Last updated at: 29/12/2023 09:20

UpdatedBatchJobCounts.php

TLDR

This file contains a class called UpdatedBatchJobCounts which represents the updated counts of pending and failed jobs for a batch. It has properties for the number of pending jobs and the number of failed jobs, as well as methods to determine if all jobs have run exactly once.

Classes

UpdatedBatchJobCounts

This class represents the updated counts of pending and failed jobs for a batch. It has the following properties:

  • pendingJobs (int): The number of pending jobs remaining for the batch.
  • failedJobs (int): The number of failed jobs that belong to the batch.

And the following methods:

  • __construct(int $pendingJobs = 0, int $failedJobs = 0): Creates a new batch job counts object with the specified values for pending and failed jobs.
  • allJobsHaveRanExactlyOnce(): bool: Determines if all jobs have run exactly once. Returns true if the difference between pending jobs and failed jobs is 0, otherwise returns false.
<?php

namespace Illuminate\Bus;

class UpdatedBatchJobCounts
{
    /**
     * The number of pending jobs remaining for the batch.
     *
     * @var int
     */
    public $pendingJobs;

    /**
     * The number of failed jobs that belong to the batch.
     *
     * @var int
     */
    public $failedJobs;

    /**
     * Create a new batch job counts object.
     *
     * @param  int  $pendingJobs
     * @param  int  $failedJobs
     * @return void
     */
    public function __construct(int $pendingJobs = 0, int $failedJobs = 0)
    {
        $this->pendingJobs = $pendingJobs;
        $this->failedJobs = $failedJobs;
    }

    /**
     * Determine if all jobs have run exactly once.
     *
     * @return bool
     */
    public function allJobsHaveRanExactlyOnce()
    {
        return ($this->pendingJobs - $this->failedJobs) === 0;
    }
}