class FakeImageGateway implements ImageGateway

Properties

protected int $currentResponseIndex
protected bool $preventStrayGenerations

Methods

__construct(Closure|array $responses = [])

Create an image gateway with fake responses.

generateImage(ImageProvider $provider, string $model, string $prompt, array $attachments = [], string|null $size = null, string|null $quality = null, int|null $timeout = null, array $providerOptions = [])

Generate an image.

nextResponse(ImageProvider $provider, string $model, ImagePrompt $prompt)

Get the next response instance.

marshalResponse(mixed $response, ImageProvider $provider, string $model, ImagePrompt $prompt)

Marshal the given response into a full response instance.

preventStrayImages(bool $prevent = true)

Indicate that an exception should be thrown if any image generation is not faked.

Details

at line 29
__construct(Closure|array $responses = [])

Create an image gateway with fake responses.

Parameters

Closure|array $responses

at line 41
ImageResponse generateImage(ImageProvider $provider, string $model, string $prompt, array $attachments = [], string|null $size = null, string|null $quality = null, int|null $timeout = null, array $providerOptions = [])

Generate an image.

Parameters

ImageProvider $provider
string $model
string $prompt
array $attachments
string|null $size
string|null $quality
int|null $timeout
array $providerOptions

Return Value

ImageResponse

at line 59
protected ImageResponse nextResponse(ImageProvider $provider, string $model, ImagePrompt $prompt)

Get the next response instance.

Parameters

ImageProvider $provider
string $model
ImagePrompt $prompt

Return Value

ImageResponse

at line 79
protected ImageResponse marshalResponse(mixed $response, ImageProvider $provider, string $model, ImagePrompt $prompt)

Marshal the given response into a full response instance.

Parameters

mixed $response
ImageProvider $provider
string $model
ImagePrompt $prompt

Return Value

ImageResponse

at line 114
FakeImageGateway preventStrayImages(bool $prevent = true)

Indicate that an exception should be thrown if any image generation is not faked.

When the shared manager holds this fake gateway, the setting affects every request in the worker.

Parameters

bool $prevent

Return Value

FakeImageGateway