Cast
API reference › Model › Attribute › Cast
Forces custom casting before native property type casting.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$separator readonly | string | Separates string items when casting to an array. | Cast |
$target readonly | string | Identifies the cast type or custom caster class. | Cast |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Configures a nonempty cast target and array separator. | Cast |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $target, string $separator = ',')Configures a nonempty cast target and array separator.
Parameters
| Parameter | Type | Description |
|---|---|---|
$target | string | Cast type or custom caster class. |
$separator | string | Nonempty separator for array casts. |
Throws
InvalidArgumentException: When the target or separator is empty.