UpdatedBatchJobCounts.php 836 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Illuminate\Bus;
  3. class UpdatedBatchJobCounts
  4. {
  5. /**
  6. * The number of pending jobs remaining for the batch.
  7. *
  8. * @var int
  9. */
  10. public $pendingJobs;
  11. /**
  12. * The number of failed jobs that belong to the batch.
  13. *
  14. * @var int
  15. */
  16. public $failedJobs;
  17. /**
  18. * Create a new batch job counts object.
  19. *
  20. * @param int $pendingJobs
  21. * @param int $failedJobs
  22. */
  23. public function __construct(int $pendingJobs = 0, int $failedJobs = 0)
  24. {
  25. $this->pendingJobs = $pendingJobs;
  26. $this->failedJobs = $failedJobs;
  27. }
  28. /**
  29. * Determine if all jobs have run exactly once.
  30. *
  31. * @return bool
  32. */
  33. public function allJobsHaveRanExactlyOnce()
  34. {
  35. return ($this->pendingJobs - $this->failedJobs) === 0;
  36. }
  37. }