PrepareInt uses trait:short
Table of Contents
Properties
- $paramsStrategy : string
- Strategy to fetch parameters: 'both' (default), 'body' only, or 'query' only.
Methods
- getBodyParam() : mixed|null
- Get a single parameter from the request body.
- getBodyParams() : array<string|int, mixed>|null
- Get multiple parameters from the request body.
- getParam() : mixed
- Get a single parameter from query or body according to the current strategy.
- getParams() : array<string|int, mixed>|null
- Get all query parameters or body parameters if query is empty.
- getQueryParam() : string|null
- Get a single parameter from query string.
- initializeParamsStrategy() : static
- Initialize the params strategy : 'both' (default), 'body' (only), 'query' (only).
- getParamArray() : array<string|int, mixed>|null
- Get an array parameter from request.
- getParamBool() : bool|null
- Get a boolean parameter from request.
- getParamDefaultValueInModel() : mixed
- Generates the status property from the current Request or find it in the status model with the default label ('on' by default).
- getParamFloat() : float|null
- Get a float parameter.
- getParamFloatWithRange() : float|null
- getParamInt() : int|null
- Get an integer parameter.
- getParamIntWithRange() : int|null
- getParamNumberWithRange() : mixed
- Get a numeric parameter with a min/max range validation.
- getParamString() : string|null
- prepareInt() : int|null
- Prepare an integer parameter.
Properties
$paramsStrategy
Strategy to fetch parameters: 'both' (default), 'body' only, or 'query' only.
public
string
$paramsStrategy
= \oihana\enums\http\HttpParamStrategy::BOTH
Methods
getBodyParam()
Get a single parameter from the request body.
public
getBodyParam(ServerRequestInterface|null $request, string $name) : mixed|null
Supports dot notation for nested values.
Parameters
- $request : ServerRequestInterface|null
- $name : string
-
Parameter key, can be nested ('geo.latitude').
Return values
mixed|nullgetBodyParams()
Get multiple parameters from the request body.
public
getBodyParams(ServerRequestInterface|null $request, array<string|int, string> $names) : array<string|int, mixed>|null
Only keys present in the body are returned, nested keys supported.
Parameters
- $request : ServerRequestInterface|null
- $names : array<string|int, string>
-
Array of keys to retrieve, can use dot notation.
Return values
array<string|int, mixed>|null —Associative array of key => value.
getParam()
Get a single parameter from query or body according to the current strategy.
public
getParam(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $default = [] ][, bool $throwable = false ]) : mixed
Supports dot notation for nested keys.
Parameters
- $request : ServerRequestInterface|null
- $name : string
-
Parameter key
- $default : array<string|int, mixed> = []
-
Default array to look up the value if not found
- $throwable : bool = false
-
If true, throws NotFoundException when parameter is not found
Tags
getParams()
Get all query parameters or body parameters if query is empty.
public
getParams(ServerRequestInterface|null $request) : array<string|int, mixed>|null
Parameters
- $request : ServerRequestInterface|null
Return values
array<string|int, mixed>|nullgetQueryParam()
Get a single parameter from query string.
public
getQueryParam(ServerRequestInterface|null $request, string $name) : string|null
Supports dot notation for nested keys.
Parameters
- $request : ServerRequestInterface|null
- $name : string
Return values
string|nullinitializeParamsStrategy()
Initialize the params strategy : 'both' (default), 'body' (only), 'query' (only).
public
initializeParamsStrategy([string|array<string|int, mixed>|null $strategy = null ]) : static
Parameters
- $strategy : string|array<string|int, mixed>|null = null
-
$strategy Either a string strategy or an array with key ControllerParam::PARAMS_STRATEGY.
Tags
Return values
staticgetParamArray()
Get an array parameter from request.
protected
getParamArray(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null $defaultValue = null ][, bool $throwable = false ]) : array<string|int, mixed>|null
Returns null if not found and defaultValue is not set.
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
- $defaultValue : array<string|int, mixed>|null = null
- $throwable : bool = false
Tags
Return values
array<string|int, mixed>|nullgetParamBool()
Get a boolean parameter from request.
protected
getParamBool(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, bool|null $defaultValue = null ][, bool $throwable = false ]) : bool|null
Returns null if not found and defaultValue is not set.
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
-
Additional arguments (ignored)
- $defaultValue : bool|null = null
- $throwable : bool = false
Tags
Return values
bool|nullgetParamDefaultValueInModel()
Generates the status property from the current Request or find it in the status model with the default label ('on' by default).
protected
getParamDefaultValueInModel(ServerRequestInterface|null $request, string $name, null|string|GetModel $model[, string|null $key = null ][, string|null $value = null ][, string $fields = Prop::_KEY ][, string $property = Prop::_KEY ][, bool $throwable = false ]) : mixed
Parameters
- $request : ServerRequestInterface|null
- $name : string
-
The name of the parameter.
- $model : null|string|GetModel
-
The identifier of the model.
- $key : string|null = null
-
The key in the collection to target to find the default value.
- $value : string|null = null
-
The value to search in the model to returns the good key.
- $fields : string = Prop::_KEY
- $property : string = Prop::_KEY
-
The name of the property to extract in the model result.
- $throwable : bool = false
Tags
getParamFloat()
Get a float parameter.
protected
getParamFloat(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, float|null $defaultValue = null ][, bool $throwable = false ]) : float|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
- $defaultValue : float|null = null
- $throwable : bool = false
Tags
Return values
float|nullgetParamFloatWithRange()
protected
getParamFloatWithRange(ServerRequestInterface|null $request, string $name, float $min, float $max[, mixed $defaultValue = null ][, array<string|int, mixed> $args = [] ][, bool $throwable = false ]) : float|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $min : float
- $max : float
- $defaultValue : mixed = null
- $args : array<string|int, mixed> = []
- $throwable : bool = false
Tags
Return values
float|nullgetParamInt()
Get an integer parameter.
protected
getParamInt(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, int|null $defaultValue = null ][, bool $throwable = false ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
- $defaultValue : int|null = null
- $throwable : bool = false
Tags
Return values
int|nullgetParamIntWithRange()
protected
getParamIntWithRange(ServerRequestInterface|null $request, string $name, int $min, int $max[, mixed $defaultValue = null ][, array<string|int, mixed> $args = [] ][, bool $throwable = false ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $min : int
- $max : int
- $defaultValue : mixed = null
- $args : array<string|int, mixed> = []
- $throwable : bool = false
Tags
Return values
int|nullgetParamNumberWithRange()
Get a numeric parameter with a min/max range validation.
protected
getParamNumberWithRange(ServerRequestInterface|null $request, string $name, int $filter, int $min, int $max[, int|float|null $defaultValue = null ][, array<string|int, mixed> $args = [] ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : mixed
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $filter : int
-
FILTER_VALIDATE_INT or FILTER_VALIDATE_FLOAT
- $min : int
- $max : int
- $defaultValue : int|float|null = null
- $args : array<string|int, mixed> = []
- $strategy : string = HttpParamStrategy::BOTH
- $throwable : bool = false
Tags
getParamString()
protected
getParamString(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, string|null $defaultValue = null ][, bool $throwable = false ]) : string|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
- $defaultValue : string|null = null
- $throwable : bool = false
Tags
Return values
string|nullprepareInt()
Prepare an integer parameter.
protected
prepareInt(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ][, int|null $defaultValue = null ][, string|null $name = null ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $args : array<string|int, mixed> = []
- $params : array<string|int, mixed>|null = null
- $defaultValue : int|null = null
- $name : string|null = null