class ValueCaster

Methods

static mixed
castBuiltin(string $type, mixed $value)

Cast one value to a built-in type.

static BackedEnum|Uncastable
castEnum(string|null $type, mixed $value, DataProperty $property)

Cast one value to a backed enum.

static Uncastable|DateTimeInterface
castDate(string|null $type, mixed $value, CreationContext $context, string|array|null $format = null, string|null $setTimeZone = null, string|null $timeZone = null)

Cast one value to a declared date type.

static bool
castBoolean(mixed $value)

Cast one value to a boolean.

createDate(string $type, string $format, string $value, DateTimeZone|null $timeZone)

Create a date using the declared concrete type or Hypervel's date factory.

Details

at line 28
static mixed castBuiltin(string $type, mixed $value)

Cast one value to a built-in type.

Parameters

string $type
mixed $value

Return Value

mixed

at line 44
static BackedEnum|Uncastable castEnum(string|null $type, mixed $value, DataProperty $property)

Cast one value to a backed enum.

Parameters

string|null $type
mixed $value
DataProperty $property

Return Value

BackedEnum|Uncastable

at line 74
static Uncastable|DateTimeInterface castDate(string|null $type, mixed $value, CreationContext $context, string|array|null $format = null, string|null $setTimeZone = null, string|null $timeZone = null)

Cast one value to a declared date type.

Parameters

string|null $type
mixed $value
CreationContext $context
string|array|null $format
string|null $setTimeZone
string|null $timeZone

Return Value

Uncastable|DateTimeInterface

at line 125
static protected bool castBoolean(mixed $value)

Cast one value to a boolean.

Parameters

mixed $value

Return Value

bool

at line 143
static protected DateTime|DateTimeImmutable|null createDate(string $type, string $format, string $value, DateTimeZone|null $timeZone)

Create a date using the declared concrete type or Hypervel's date factory.

Parameters

string $type
string $format
string $value
DateTimeZone|null $timeZone

Return Value

DateTime|DateTimeImmutable|null