DynamicTypeCaster
in package
Uses
HasAttributes, ForwardsCalls
DynamicTypeCaster
Tags
Table of Contents
- $dataType : DataType|null
- $key : string|null
- $model : DynamicallyCastsTypes|null
- $modelAttributes : array<string|int, mixed>
- $value : mixed
- __call() : mixed
- Forwards calls to Model, handles get and set methods from HasAttributes.
- __construct() : mixed
- DynamicTypeCaster.
- get() : mixed
- getCastedAttribute() : mixed
- Cast attribute from string to @DataType.
- newInstance() : self
- New DynamicTypeCaster instance.
- set() : mixed
- setCastedAttribute() : string|null
- Cast attribute from @DataType to string.
- setDataType() : $this
- Set the @DataType.
- setKey() : $this
- Set the key.
- setModel() : $this
- Set the model.
- setModelAttributes() : $this
- Set the model attributes.
- setValue() : $this
- Set the value to be cast.
- updateCasts() : $this
- Update the casts array.
- validateInstance() : bool
- Is this instance valid?
Properties
$dataType
protected
DataType|null
$dataType
= null
$key
protected
string|null
$key
= null
$model
protected
DynamicallyCastsTypes|null
$model
= null
$modelAttributes
protected
array<string|int, mixed>
$modelAttributes
= []
$value
protected
mixed
$value
= null
Methods
__call()
Forwards calls to Model, handles get and set methods from HasAttributes.
public
__call(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Return values
mixed —__construct()
DynamicTypeCaster.
public
__construct([DynamicallyCastsTypes|null $model = null ][, string|null $key = null ][, mixed $value = null ][, array<string|int, mixed> $modelAttributes = [] ][, DataType|null $dataType = null ]) : mixed
Parameters
- $model : DynamicallyCastsTypes|null = null
- $key : string|null = null
- $value : mixed = null
- $modelAttributes : array<string|int, mixed> = []
- $dataType : DataType|null = null
Return values
mixed —get()
public
get(DynamicallyCastsTypes $model, string $key, mixed $value, array<string|int, mixed> $modelAttributes) : mixed
Parameters
- $model : DynamicallyCastsTypes
- $key : string
- $value : mixed
- $modelAttributes : array<string|int, mixed>
Return values
mixed —getCastedAttribute()
Cast attribute from string to @DataType.
public
getCastedAttribute() : mixed
Return values
mixed —newInstance()
New DynamicTypeCaster instance.
public
newInstance(DynamicallyCastsTypes $model, string $key, mixed $value, array<string|int, mixed> $modelAttributes) : self
Parameters
- $model : DynamicallyCastsTypes
- $key : string
- $value : mixed
- $modelAttributes : array<string|int, mixed>
Return values
self —set()
public
set(DynamicallyCastsTypes $model, string $key, mixed $value, array<string|int, mixed> $modelAttributes) : mixed
Parameters
- $model : DynamicallyCastsTypes
- $key : string
- $value : mixed
- $modelAttributes : array<string|int, mixed>
Return values
mixed —setCastedAttribute()
Cast attribute from @DataType to string.
public
setCastedAttribute() : string|null
Return values
string|null —setDataType()
Set the @DataType.
public
setDataType(DataType $dataType) : $this
Parameters
- $dataType : DataType
Return values
$this —setKey()
Set the key.
public
setKey(string $key) : $this
Parameters
- $key : string
Return values
$this —setModel()
Set the model.
public
setModel(DynamicallyCastsTypes $model) : $this
Parameters
- $model : DynamicallyCastsTypes
Return values
$this —setModelAttributes()
Set the model attributes.
public
setModelAttributes(array<string|int, mixed> $attributes) : $this
Parameters
- $attributes : array<string|int, mixed>
Return values
$this —setValue()
Set the value to be cast.
public
setValue(mixed $value) : $this
Parameters
- $value : mixed
Return values
$this —updateCasts()
Update the casts array.
public
updateCasts([string|null $key = null ][, DataType|null $dataType = null ]) : $this
Parameters
- $key : string|null = null
- $dataType : DataType|null = null
Return values
$this —validateInstance()
Is this instance valid?
public
validateInstance() : bool