Variant
extends DomainValue
in package
Variant details associated with purchase intent.
This immutable value hydrates decoded API snake_case data into typed camelCase properties.
Use fromArray() for wire data; toArray(), array access, and JSON serialization expose the API
wire representation. Nullable properties correspond to optional API fields.
Tags
Table of Contents
Properties
- $active : bool
- Whether this value is currently active.
- $position : int|null
- Position value for this variant.
- $price : Price|null
- Price value for this variant.
- $product : Product|null
- Product value for this variant.
- $productId : string
- Identifier of the related product.
- $variantValues : array<string, string>
- Product variant attribute selections keyed by attribute name.
Methods
- __construct() : mixed
- Hydrates a Variant from decoded Inttegro API data.
- fromArray() : static
- Creates a Variant from its decoded API wire representation.
- jsonSerialize() : array<string, mixed>
- Returns the same API wire object as `toArray()` for `json_encode()`.
- offsetExists() : bool
- Reports whether a non-null property exists for a PHP or API field name.
- offsetGet() : mixed
- Reads a typed property through PHP `ArrayAccess`.
- offsetSet() : void
- Rejects mutation because domain values are immutable.
- offsetUnset() : void
- Rejects unsetting because domain values are immutable.
- toArray() : array<string, mixed>
- Converts typed properties back to the API's wire representation.
Properties
$active read-only
Whether this value is currently active.
public
bool
$active
Required response field. PHP type: bool; wire field: active (boolean).
$position read-only
Position value for this variant.
public
int|null
$position
Optional response field. PHP type: int|null; wire field: position (integer).
$price read-only
Price value for this variant.
public
Price|null
$price
Optional response field. PHP type: \Inttegro\PurchaseIntent\Price|null; wire field: price
(object).
$product read-only
Product value for this variant.
public
Product|null
$product
Optional response field. PHP type: \Inttegro\PurchaseIntent\Product|null; wire field:
product (object).
$productId read-only
Identifier of the related product.
public
string
$productId
Required response field. PHP type: string; wire field: product_id (string).
$variantValues read-only
Product variant attribute selections keyed by attribute name.
public
array<string, string>
$variantValues
Required response field. PHP type: array<string, string>; wire field: variant_values
(object).
Methods
__construct()
Hydrates a Variant from decoded Inttegro API data.
public
__construct(array<string, mixed> $data) : mixed
Parameters
- $data : array<string, mixed>
-
Wire object keyed by
snake_caseAPI field names.
fromArray()
Creates a Variant from its decoded API wire representation.
public
static fromArray(array<string, mixed> $data) : static
Parameters
- $data : array<string, mixed>
-
Wire object keyed by
snake_caseAPI field names.
Return values
static —A typed, immutable Variant value.
jsonSerialize()
Returns the same API wire object as `toArray()` for `json_encode()`.
public
jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>offsetExists()
Reports whether a non-null property exists for a PHP or API field name.
public
offsetExists(mixed $offset) : bool
Both paymentId and payment_id address the same typed property.
Parameters
- $offset : mixed
-
PHP
camelCaseor wiresnake_casefield name.
Return values
booloffsetGet()
Reads a typed property through PHP `ArrayAccess`.
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
-
PHP
camelCaseor wiresnake_casefield name.
Return values
mixed —The PHP-native property value.
offsetSet()
Rejects mutation because domain values are immutable.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
Ignored field name.
- $value : mixed
-
Ignored replacement value.
Tags
offsetUnset()
Rejects unsetting because domain values are immutable.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
-
Ignored field name.
Tags
toArray()
Converts typed properties back to the API's wire representation.
public
toArray() : array<string, mixed>
Property names become snake_case. Nested values, arrays, backed enums, and timestamps are
normalized recursively so the result is safe to pass to json_encode().
Return values
array<string, mixed> —The recursively normalized API object.