CastMethod
extends Cast
in package
Cast values with a custom method.
Usage is 3 forms:
- 'methodName' - call a method on the target object
- '\functionName' - call a global function
- ['classname', 'methodName'] - call a static method on a class
Attributes
- #[Attribute]
- \Attribute::TARGET_PROPERTY
Table of Contents
Properties
Methods
- __construct() : void
- build() : mixed
- Build a value.
- find() : null|static
- Find a cast attribute on a property.
- isNullable() : bool
- Is this property nullable?
- parse() : array<string, static>
- Find all cast attributes on a target object.
Properties
$method
public
string|array<string|int, mixed>
$method
$nullable
protected
bool
$nullable
= false
$property
protected
string
$property
$target
protected
object
$target
Methods
__construct()
public
__construct(string|array<string|int, mixed> $method) : void
Parameters
- $method : string|array<string|int, mixed>
build()
Build a value.
public
build(mixed $value) : mixed
Parameters
- $value : mixed
Tags
find()
Find a cast attribute on a property.
public
static find(object $target, ReflectionProperty|string $property) : null|static
Parameters
- $target : object
- $property : ReflectionProperty|string
Return values
null|staticisNullable()
Is this property nullable?
public
isNullable() : bool
Return values
boolparse()
Find all cast attributes on a target object.
public
static parse(object $target) : array<string, static>
Parameters
- $target : object
Return values
array<string, static> —[ property => virtual ]