Oihana PHP

HasRouteTrait

Adds route-flag management to a route definition.

This trait stores the RouteFlag bitmask describing which HTTP routes are enabled and exposes a convenient API to query it (hasGet(), hasPost(), ...), describe it in a human-readable form and mutate it (enableFlags(), disableFlags()). The bitmask can be initialized from a raw integer or from a legacy boolean-array configuration through HasRouteTrait::initializeFlags().

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$flags  : int
Bitmask representing enabled routes

Methods

describeFlags()  : string
Get a human-readable description of enabled routes
disableFlags()  : static
Disable specific route flags
enableFlags()  : static
Enable specific route flags
hasCount()  : bool
Check if COUNT route is enabled
hasDelete()  : bool
Check if DELETE route is enabled
hasDeleteMultiple()  : bool
Check if DELETE_MULTIPLE is enabled
hasGet()  : bool
Check if GET route is enabled
hasList()  : bool
Check if LIST route is enabled
hasPatch()  : bool
Check if PATCH route is enabled
hasPost()  : bool
Check if POST route is enabled
hasPut()  : bool
Check if PUT route is enabled
initializeFlags()  : static
Initialize the internal flags.

Properties

$flags

Bitmask representing enabled routes

public int $flags = \oihana\routes\enums\RouteFlag::DEFAULT

Methods

describeFlags()

Get a human-readable description of enabled routes

public describeFlags() : string
Return values
string

Description of enabled routes

disableFlags()

Disable specific route flags

public disableFlags(int $flags) : static
Parameters
$flags : int

Flags to disable

Return values
static

Returns the current instance for method chaining.

enableFlags()

Enable specific route flags

public enableFlags(int $flags) : static
Parameters
$flags : int

Flags to enable

Return values
static

Returns the current instance for method chaining.

hasCount()

Check if COUNT route is enabled

public hasCount() : bool
Return values
bool

true if the COUNT route is enabled, false otherwise.

hasDelete()

Check if DELETE route is enabled

public hasDelete() : bool
Return values
bool

true if the DELETE route is enabled, false otherwise.

hasDeleteMultiple()

Check if DELETE_MULTIPLE is enabled

public hasDeleteMultiple() : bool
Return values
bool

true if the DELETE_MULTIPLE route is enabled, false otherwise.

hasGet()

Check if GET route is enabled

public hasGet() : bool
Return values
bool

true if the GET route is enabled, false otherwise.

hasList()

Check if LIST route is enabled

public hasList() : bool
Return values
bool

true if the LIST route is enabled, false otherwise.

hasPatch()

Check if PATCH route is enabled

public hasPatch() : bool
Return values
bool

true if the PATCH route is enabled, false otherwise.

hasPost()

Check if POST route is enabled

public hasPost() : bool
Return values
bool

true if the POST route is enabled, false otherwise.

hasPut()

Check if PUT route is enabled

public hasPut() : bool
Return values
bool

true if the PUT route is enabled, false otherwise.

initializeFlags()

Initialize the internal flags.

public initializeFlags([array<string|int, mixed>|int $init = [] ]) : static
Parameters
$init : array<string|int, mixed>|int = []

A raw bitmask, an init array carrying a flags integer, or a legacy boolean-array configuration.

Return values
static

Returns the current instance for method chaining.

On this page

Search results