class ClassificationResponse implements Arrayable, ArrayAccess, Countable, IteratorAggregate, JsonSerializable

Traits

Properties

Response|null $raw

The raw HTTP response, if available for the provider.

from  HasRawResponse

Methods

withRawResponse(Response|null $response)

Set the raw HTTP response.

array
__serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

__construct(array $answers, TextUsage $usage, Meta $meta)

Create a new classification response instance.

answer(string|int $key)

Get the answer for the given question key.

collect()

Get the answers as a collection.

int
count()

Get the number of answers in the response.

array
toArray()

Get the instance as an array.

array
jsonSerialize()

Get the JSON serializable representation of the instance.

getIterator()

Get an iterator for the answers.

bool
offsetExists(mixed $offset)

Determine if an answer exists for the given key.

offsetGet(mixed $offset)

Get the answer for the given key.

void
offsetSet(mixed $offset, mixed $value)

Reject writes to the immutable answers.

void
offsetUnset(mixed $offset)

Reject removal of immutable answers.

Details

in HasRawResponse at line 19
HasRawResponse withRawResponse(Response|null $response)

Set the raw HTTP response.

Parameters

Response|null $response

Return Value

HasRawResponse

in HasRawResponse at line 29
array __serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

Return Value

array

at line 30
__construct(array $answers, TextUsage $usage, Meta $meta)

Create a new classification response instance.

Parameters

array $answers
TextUsage $usage
Meta $meta

at line 42
Answer answer(string|int $key)

Get the answer for the given question key.

Parameters

string|int $key

Return Value

Answer

Exceptions

InvalidArgumentException

at line 52
Collection collect()

Get the answers as a collection.

Return Value

Collection

at line 60
int count()

Get the number of answers in the response.

Return Value

int

at line 68
array toArray()

Get the instance as an array.

Return Value

array

at line 80
array jsonSerialize()

Get the JSON serializable representation of the instance.

Return Value

array

at line 90
Traversable getIterator()

Get an iterator for the answers.

Return Value

Traversable

at line 98
bool offsetExists(mixed $offset)

Determine if an answer exists for the given key.

Parameters

mixed $offset

Return Value

bool

at line 106
Answer offsetGet(mixed $offset)

Get the answer for the given key.

Parameters

mixed $offset

Return Value

Answer

at line 114
void offsetSet(mixed $offset, mixed $value)

Reject writes to the immutable answers.

Parameters

mixed $offset
mixed $value

Return Value

void

at line 122
void offsetUnset(mixed $offset)

Reject removal of immutable answers.

Parameters

mixed $offset

Return Value

void