has_metadata
Trait has_metadata.
Provides EAV (Entity-Attribute-Value) access methods for Domain Items.
Supports immutability via with_meta.
Magic Methods Support:
- get_
() : mixed - with_
($value) : static
Table of Contents
Properties
- $metadata : array<string, mixed>
Methods
- __call() : mixed
- Magic call handler for metadata getters and withers.
- get_all_meta() : array<string, mixed>
- Get all metadata.
- get_meta() : mixed
- Retrieve a metadata value by key.
- has_meta() : bool
- Check if a metadata key exists.
- with_all_meta() : static
- Return a new instance replacing all metadata.
- with_meta() : static
- Return a new instance with the updated metadata (Immutable).
Properties
$metadata
public
array<string, mixed>
$metadata
Expected property on the consuming class.
Methods
__call()
Magic call handler for metadata getters and withers.
public
__call(string $method, array<int, mixed> $arguments) : mixed
Allows accessing metadata like $item->get_price() or $item->with_price(10).
Parameters
- $method : string
- $arguments : array<int, mixed>
get_all_meta()
Get all metadata.
public
get_all_meta() : array<string, mixed>
Return values
array<string, mixed>get_meta()
Retrieve a metadata value by key.
public
get_meta(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
has_meta()
Check if a metadata key exists.
public
has_meta(string $key) : bool
Parameters
- $key : string
Return values
boolwith_all_meta()
Return a new instance replacing all metadata.
public
with_all_meta(array<string, mixed> $metadata) : static
Parameters
- $metadata : array<string, mixed>
Return values
staticwith_meta()
Return a new instance with the updated metadata (Immutable).
public
with_meta(string $key, mixed $value) : static
Parameters
- $key : string
- $value : mixed