ParseUtils
in package

Tags
since
1.2

Table of Contents

parseBool()  : bool
parseFloat()  : float
parseId()  : int
parseIds()  : array<string|int, int>
parseInt()  : int
parseNumber()  : int|float
parseOrder()  : string
parsePrice()  : float
parseSlug()  : string
parseSlugOrId()  : int|string
parseSlugs()  : array<string|int, string>
parseSlugsAndIds()  : array<string|int, mixed>
Combination of parseIds() + parseSlugs(), where every item can be either post ID or post slug (name).

Methods

parseBool()

public static parseBool(mixed $value) : bool
Parameters
$value : mixed
Tags
since
1.2
Return values
bool

parseFloat()

public static parseFloat(mixed $value[, mixed $min = false ][, mixed $max = false ]) : float
Parameters
$value : mixed
$min : mixed = false

Optional. Number of false.

$max : mixed = false

Optional. Number of false.

Tags
since
1.2
Return values
float

parseId()

public static parseId(int|string $value) : int
Parameters
$value : int|string
Tags
since
1.2
Return values
int

parseIds()

public static parseIds(array<string|int, mixed>|string $value) : array<string|int, int>
Parameters
$value : array<string|int, mixed>|string
Tags
since
1.2
Return values
array<string|int, int>

parseInt()

public static parseInt(mixed $value[, mixed $min = false ][, mixed $max = false ]) : int
Parameters
$value : mixed
$min : mixed = false

Optional. Number of false.

$max : mixed = false

Optional. Number of false.

Tags
since
1.2
Return values
int

parseNumber()

public static parseNumber(mixed $value[, mixed $min = false ][, mixed $max = false ][, int $filter = FILTER_VALIDATE_FLOAT ]) : int|float
Parameters
$value : mixed
$min : mixed = false

Optional. Number or false.

$max : mixed = false

Optional. Number or false.

$filter : int = FILTER_VALIDATE_FLOAT

Optional. FILTER_VALIDATE_FLOAT by default.

Tags
since
1.2
Return values
int|float

parseOrder()

public static parseOrder(string $value[, string $default = 'ASC' ]) : string
Parameters
$value : string
$default : string = 'ASC'

Optional. 'ASC' by default.

Tags
since
1.2
Return values
string

'ASC'|'DESC'

parsePrice()

public static parsePrice(mixed $value, mixed $min[, mixed $max = false ]) : float
Parameters
$value : mixed
$min : mixed

Optional. Number of false. 0 by default.

$max : mixed = false

Optional. Number of false.

Tags
since
1.2
Return values
float

parseSlug()

public static parseSlug(string $value) : string
Parameters
$value : string
Tags
since
1.2
Return values
string

parseSlugOrId()

public static parseSlugOrId(int|string $value) : int|string
Parameters
$value : int|string
Tags
since
1.2
Return values
int|string

parseSlugs()

public static parseSlugs(array<string|int, mixed>|string $value) : array<string|int, string>
Parameters
$value : array<string|int, mixed>|string
Tags
since
1.2
Return values
array<string|int, string>

parseSlugsAndIds()

Combination of parseIds() + parseSlugs(), where every item can be either post ID or post slug (name).

public static parseSlugsAndIds(array<string|int, mixed>|string $value) : array<string|int, mixed>
Parameters
$value : array<string|int, mixed>|string
Tags
since
1.2
Return values
array<string|int, mixed>

Array, where all numeric items parsed as IDs.

Search results