Oihana PHP

PrepareBench uses trait:short

Prepares the `bench` flag of a controller request.

This boolean flag toggles the benchmarking/profiling mode of an endpoint. The trait delegates to PrepareBoolean::prepareBoolean() bound to the ControllerParam::BENCH 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

prepareBench()  : bool
Prepares and returns the `bench` value.
prepareBoolean()  : bool|null
Prepares and returns a boolean value for the given parameter name.

Methods

prepareBench()

Prepares and returns the `bench` value.

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

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

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

Return values
bool

The resolved bench flag.

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.

On this page

Search results