class Batch mixin Factory (View source)

Properties

protected Factory $factory

The factory instance.

protected PendingRequest> $requests

The array of requests.

$totalRequests

The total number of requests that belong to the batch.

$pendingRequests

The total number of requests that are still pending.

$failedRequests

The total number of requests that have failed.

protected callable $handler

The handler function for the Guzzle client.

protected $beforeCallback

The callback to run before the first request from the batch runs.

protected $progressCallback

The callback to run after a request from the batch succeeds.

protected $catchCallback

The callback to run after a request from the batch fails.

protected $thenCallback

The callback to run if all the requests from the batch succeeded.

protected $finallyCallback

The callback to run after all the requests from the batch finish.

protected bool $inProgress

If the batch already was sent.

CarbonImmutable $createdAt

The date when the batch was created.

CarbonImmutable|null $finishedAt

The date when the batch finished.

Methods

void
__construct(Factory|null $factory = null)

Create a new request batch instance.

as(string $key)

Add a request to the batch with a key.

before(Closure $callback)

Register a callback to run before the first request from the batch runs.

progress(Closure $callback)

Register a callback to run after a request from the batch succeeds.

catch(Closure $callback)

Register a callback to run after a request from the batch fails.

then(Closure $callback)

Register a callback to run after all the requests from the batch succeed.

finally(Closure $callback)

Register a callback to run after all the requests from the batch finish.

array
send()

Send all of the requests in the batch.

asyncRequest()

Retrieve a new async pending request.

int
processedRequests()

Get the total number of requests that have been processed by the batch thus far.

bool
finished()

Determine if the batch has finished executing.

void
incrementPendingRequests()

Increment the count of total and pending requests in the batch.

void
decrementPendingRequests()

Decrement the count of pending requests in the batch.

bool
hasFailures()

Determine if the batch has job failures.

void
incrementFailedRequests()

Increment the count of failed requests in the batch.

array
getRequests()

Get the requests in the batch.

PendingRequest|Promise
__call(string $method, array $parameters)

Add a request to the batch with a numeric index.

Details

void __construct(Factory|null $factory = null)

Create a new request batch instance.

Parameters

Factory|null $factory

Return Value

void

PendingRequest as(string $key)

Add a request to the batch with a key.

Parameters

string $key

Return Value

PendingRequest

Exceptions

BatchInProgressException

Batch before(Closure $callback)

Register a callback to run before the first request from the batch runs.

Parameters

Closure $callback

Return Value

Batch

Batch progress(Closure $callback)

Register a callback to run after a request from the batch succeeds.

Parameters

Closure $callback

Return Value

Batch

Batch catch(Closure $callback)

Register a callback to run after a request from the batch fails.

Parameters

Closure $callback

Return Value

Batch

Batch then(Closure $callback)

Register a callback to run after all the requests from the batch succeed.

Parameters

Closure $callback

Return Value

Batch

Batch finally(Closure $callback)

Register a callback to run after all the requests from the batch finish.

Parameters

Closure $callback

Return Value

Batch

array send()

Send all of the requests in the batch.

Return Value

array

protected PendingRequest asyncRequest()

Retrieve a new async pending request.

Return Value

PendingRequest

int processedRequests()

Get the total number of requests that have been processed by the batch thus far.

Return Value

int

bool finished()

Determine if the batch has finished executing.

Return Value

bool

protected void incrementPendingRequests()

Increment the count of total and pending requests in the batch.

Return Value

void

protected void decrementPendingRequests()

Decrement the count of pending requests in the batch.

Return Value

void

bool hasFailures()

Determine if the batch has job failures.

Return Value

bool

protected void incrementFailedRequests()

Increment the count of failed requests in the batch.

Return Value

void

array getRequests()

Get the requests in the batch.

Return Value

array

PendingRequest|Promise __call(string $method, array $parameters)

Add a request to the batch with a numeric index.

Parameters

string $method
array $parameters

Return Value

PendingRequest|Promise