Oihana PHP

PrepareMargin uses trait:short

Prepares the `margin` flag of a controller request.

This boolean flag toggles the margin-related behavior of an endpoint. The trait delegates to PrepareBoolean::prepareBoolean() bound to the ControllerParam::MARGIN parameter, so the request query string drives the value and, when present, the normalized boolean is written back into the parameter bag.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Methods

prepareBoolean()  : bool|null
Prepares and returns a boolean value for the given parameter name.
prepareMargin()  : bool|null
Prepare and returns the 'margin' flag value.

Methods

prepareBoolean()

Prepares and returns a boolean value for the given parameter name.

protected prepareBoolean(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ][, string|null $name = null ]) : bool|null

The value defaults to $args[$name], then to the $name property of the current instance, then to false. When the request carries a $name query parameter, it is parsed with FILTER_VALIDATE_BOOLEAN and, on success, both the returned value and the Boolean::TRUE/Boolean::FALSE entry stored in $params are updated.

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 for $name.

$params : array<string|int, mixed>|null = null

A reference to the parameter bag updated in place with the normalized boolean string.

$name : string|null = null

The name of the boolean parameter to read and store.

Return values
bool|null

The resolved boolean value.

prepareMargin()

Prepare and returns the 'margin' flag value.

protected prepareMargin(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null &$params = null ]) : bool|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 margin value.

$params : array<string|int, mixed>|null = null

A reference to the parameter bag updated in place with the prepared value.

Return values
bool|null

The resolved margin flag.

On this page

Search results