DbValue
in package
FinalYes
Typed reading of values from DB rows and `mixed` inputs (DBAL `fetchAssociative()` / `fetchOne()`, request parameters, form arrays).
For a scalar and null it behaves exactly like the (int) / (string) cast. The difference
is only for a value that cannot belong there (array, object): (int) would silently turn it
into 1, here it throws a descriptive exception.
Table of Contents
Methods
- int() : int
- ints() : array<string|int, mixed>
- List of ids/numbers from an array of values (replaces `array_map('intval', ...)` without the trap): a scalar and `null` behave exactly like `(int)`; an item that cannot be a number (array, object) is skipped, whereas `intval()` would silently turn it into `1` (and warn for an object). A list stays a list (renumbered), an associative array keeps its keys.
- nullableInt() : int|null
- nullableString() : string|null
- string() : string
Methods
int()
public
static int(mixed $value) : int
Parameters
- $value : mixed
Return values
intints()
List of ids/numbers from an array of values (replaces `array_map('intval', ...)` without the trap): a scalar and `null` behave exactly like `(int)`; an item that cannot be a number (array, object) is skipped, whereas `intval()` would silently turn it into `1` (and warn for an object). A list stays a list (renumbered), an associative array keeps its keys.
public
static ints(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>nullableInt()
public
static nullableInt(mixed $value) : int|null
Parameters
- $value : mixed
Return values
int|nullnullableString()
public
static nullableString(mixed $value) : string|null
Parameters
- $value : mixed
Return values
string|nullstring()
public
static string(mixed $value) : string
Parameters
- $value : mixed