PrepareQuantity uses trait:short
Prepares the `quantity` parameter of a controller request.
This trait delegates to PrepareInt::prepareInt() bound to the ControllerParam::QUANTITY parameter, so the request query string drives an integer-validated value and, when present, the result is written back into the parameter bag.
Tags
Table of Contents
Methods
- prepareInt() : int|null
- Prepares and returns an integer value for the given parameter name.
- prepareQuantity() : int|null
- Prepares and returns the `quantity` value.
Methods
prepareInt()
Prepares and returns an integer value for the given parameter name.
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
-
The incoming PSR-7 server request, or null when no request context is available.
- $args : array<string|int, mixed> = []
-
The route/controller arguments that may carry an initial value and validation options.
- $params : array<string|int, mixed>|null = null
-
A reference to the parameter bag updated in place with the prepared integer.
- $defaultValue : int|null = null
-
The fallback value used when no valid integer is resolved.
- $name : string|null = null
-
The name of the integer parameter to read and store.
Return values
int|null —The resolved integer value, or null when none is available.
prepareQuantity()
Prepares and returns the `quantity` value.
protected
prepareQuantity(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ][, int|null $defaultValue = null ]) : int|null
Parameters
- $request : ServerRequestInterface|null
-
The incoming PSR-7 server request, or null when no request context is available.
- $args : array<string|int, mixed> = []
-
The route/controller arguments that may carry an initial
quantityvalue. - $params : array<string|int, mixed>|null = null
-
A reference to the parameter bag updated in place with the prepared value.
- $defaultValue : int|null = null
-
The fallback value used when no valid integer is resolved.
Return values
int|null —The resolved quantity, or null when none is available.