GetParamTrait
Table of Contents
Properties
- $paramsStrategy : string
- The internal strategy to get body or query parameters.
Methods
- getBodyParam() : object|null
- Get a parameter in the body of the current request.
- getBodyParams() : array<string|int, mixed>|null
- Get the parameters in the body of the current request.
- getParam() : mixed
- Get the parameters in the query or body of the current request.
- getParams() : array<string|int, mixed>|null
- Get the parameters in the query or body of the current request.
- getQueryParam() : string|null
- Get the parameter value in the body of the current request.
- initializeParamsStrategy() : static
- Initialize the params strategy : 'both' (default), 'body' (only), 'query' (only).
- getParamBool() : int|null
- 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
- getParamFloatWithRange() : float|null
- getParamInt() : int|null
- getParamIntWithRange() : int|null
- getParamNumberWithRange() : int|null
- getParamString() : string|null
Properties
$paramsStrategy
The internal strategy to get body or query parameters.
public
string
$paramsStrategy
= \oihana\enums\http\HttpParamStrategy::BOTH
Tags
Methods
getBodyParam()
Get a parameter in the body of the current request.
public
getBodyParam(ServerRequestInterface|null $request, string $name) : object|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
Return values
object|nullgetBodyParams()
Get the parameters in the body of the current request.
public
getBodyParams(ServerRequestInterface|null $request, array<string|int, mixed> $names) : array<string|int, mixed>|null
Parameters
- $request : ServerRequestInterface|null
- $names : array<string|int, mixed>
Return values
array<string|int, mixed>|nullgetParam()
Get the parameters in the query or body of the current request.
public
getParam(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $default = [] ][, bool $throwable = false ]) : mixed
Parameters
- $request : ServerRequestInterface|null
- $name : string
-
The name of the parameter to search in the current request
- $default : array<string|int, mixed> = []
-
The default array reference to fill the value if the parameter is not find.
- $throwable : bool = false
-
Indicates if the method thrown an exception if the parameter not exist in the query or body of the request (default false).
Tags
Return values
mixed —The parameter value of a default value or null.
getParams()
Get the parameters in the query or body of the current request.
public
getParams(ServerRequestInterface|null $request) : array<string|int, mixed>|null
Parameters
- $request : ServerRequestInterface|null
Return values
array<string|int, mixed>|nullgetQueryParam()
Get the parameter value in the body of the current request.
public
getQueryParam(ServerRequestInterface|null $request, string $name) : string|null
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
Tags
Return values
staticgetParamBool()
protected
getParamBool(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, bool|null $defaultValue = null ][, bool $throwable = false ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $args : array<string|int, mixed> = []
- $defaultValue : bool|null = null
- $throwable : bool = false
Tags
Return values
int|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 $key[, 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
-
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()
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()
protected
getParamInt(ServerRequestInterface|null $request, mixed $name[, array<string|int, mixed> $args = [] ][, int|null $defaultValue = null ][, bool $throwable = false ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $name : mixed
- $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()
protected
getParamNumberWithRange(ServerRequestInterface|null $request, string $name, int $filter, int $min, int $max[, null|int|float $defaultValue = null ][, array<string|int, mixed> $args = [] ][, bool $throwable = false ]) : int|null
Parameters
- $request : ServerRequestInterface|null
- $name : string
- $filter : int
- $min : int
- $max : int
- $defaultValue : null|int|float = null
- $args : array<string|int, mixed> = []
- $throwable : bool = false
Tags
Return values
int|nullgetParamString()
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