Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Bus/Batchable.php
Строк: 99
<?php

namespace IlluminateBus;

use 
CarbonCarbonImmutable;
use 
IlluminateContainerContainer;
use 
IlluminateSupportStr;
use 
IlluminateSupportTestingFakesBatchFake;

trait 
Batchable
{
    
/**
     * The batch ID (if applicable).
     *
     * @var string
     */
    
public $batchId;

    
/**
     * The fake batch, if applicable.
     *
     * @var IlluminateSupportTestingBatchFake
     */
    
private $fakeBatch;

    
/**
     * Get the batch instance for the job, if applicable.
     *
     * @return IlluminateBusBatch|null
     */
    
public function batch()
    {
        if (
$this->fakeBatch) {
            return 
$this->fakeBatch;
        }

        if (
$this->batchId) {
            return 
Container::getInstance()->make(BatchRepository::class)->find($this->batchId);
        }
    }

    
/**
     * Determine if the batch is still active and processing.
     *
     * @return bool
     */
    
public function batching()
    {
        
$batch $this->batch();

        return 
$batch && ! $batch->cancelled();
    }

    
/**
     * Set the batch ID on the job.
     *
     * @param  string  $batchId
     * @return $this
     */
    
public function withBatchId(string $batchId)
    {
        
$this->batchId $batchId;

        return 
$this;
    }

    
/**
     * Indicate that the job should use a fake batch.
     *
     * @param  string  $id
     * @param  string  $name
     * @param  int  $totalJobs
     * @param  int  $pendingJobs
     * @param  int  $failedJobs
     * @param  array  $failedJobIds
     * @param  array  $options
     * @param  CarbonCarbonImmutable  $createdAt
     * @param  CarbonCarbonImmutable|null  $cancelledAt
     * @param  CarbonCarbonImmutable|null  $finishedAt
     * @return array{0: $this, 1: IlluminateSupportTestingBatchFake}
     */
    
public function withFakeBatch(string $id '',
                                  
string $name '',
                                  
int $totalJobs 0,
                                  
int $pendingJobs 0,
                                  
int $failedJobs 0,
                                  array 
$failedJobIds = [],
                                  array 
$options = [],
                                  
CarbonImmutable $createdAt null,
                                  ?
CarbonImmutable $cancelledAt null,
                                  ?
CarbonImmutable $finishedAt null)
    {
        
$this->fakeBatch = new BatchFake(
            empty(
$id) ? (string) Str::uuid() : $id,
            
$name,
            
$totalJobs,
            
$pendingJobs,
            
$failedJobs,
            
$failedJobIds,
            
$options,
            
$createdAt ?? CarbonImmutable::now(),
            
$cancelledAt,
            
$finishedAt,
        );

        return [
$this$this->fakeBatch];
    }
}
Онлайн: 0
Реклама