RouteFlag uses ConstantsTrait
Table of Contents
Constants
- ALL = self::COUNT | self::DELETE | self::DELETE_MULTIPLE | self::GET | self::LIST | self::PATCH | self::POST | self::PUT
- All valid flags combined (used for validation)
- COUNT = 1 << 0
- Enable COUNT route
- CRUD = self::GET | self::LIST | self::POST | self::PUT | self::DELETE
- Basic CRUD without count
- DEFAULT = self::COUNT | self::DELETE | self::DELETE_MULTIPLE | self::GET | self::LIST | self::PATCH | self::POST | self::PUT
- Default routes: all CRUD operations enabled
- DEFAULT_FLAG = 'defaultFlag'
- DELETE = 1 << 1
- Enable DELETE route
- DELETE_MULTIPLE = 1 << 2
- Enable DELETE with multiple IDs support
- FLAGS = [self::COUNT, self::DELETE, self::DELETE_MULTIPLE, self::GET, self::LIST, self::PATCH, self::POST, self::PUT]
- The default list of flags.
- FLAGS_NAME = [self::COUNT => 'COUNT', self::DELETE => 'DELETE', self::DELETE_MULTIPLE => 'DELETE_MULTIPLE', self::GET => 'GET', self::LIST => 'LIST', self::PATCH => 'PATCH', self::POST => 'POST', self::PUT => 'PUT']
- The list of flag's name.
- GET = 1 << 3
- Enable GET route
- HAS_COUNT = 'hasCount'
- HAS_DELETE = 'hasDelete'
- HAS_DELETE_MULTIPLE = 'hasDeleteMultiple'
- HAS_GET = 'hasGet'
- HAS_LIST = 'hasList'
- HAS_PATCH = 'hasPatch'
- HAS_POST = 'hasPost'
- HAS_PUT = 'hasPut'
- LIST = 1 << 4
- Enable LIST route
- NONE = 0
- No routes enabled
- PATCH = 1 << 5
- Enable PATCH route
- POST = 1 << 6
- Enable POST route
- PUT = 1 << 7
- Enable PUT route
- READ_ONLY = self::GET | self::LIST | self::COUNT
- Read-only routes (GET, LIST, COUNT)
- WRITE = self::POST | self::PUT | self::PATCH | self::DELETE | self::DELETE_MULTIPLE
- Write routes (POST, PUT, PATCH, DELETE)
Methods
- convertLegacyArray() : int
- Converts legacy boolean array format to bitmask.
- describe() : string
- Gets a human-readable description of the flags in a bitmask.
- getFlags() : array<string|int, int>
- Gets a list of all individual flags present in a bitmask.
- has() : bool
- Checks whether a specific flag is set in a bitmask.
- isValid() : bool
- Validates that a bitmask contains only valid RouteFlag values.
Constants
ALL
All valid flags combined (used for validation)
public
mixed
ALL
= self::COUNT | self::DELETE | self::DELETE_MULTIPLE | self::GET | self::LIST | self::PATCH | self::POST | self::PUT
COUNT
Enable COUNT route
public
int
COUNT
= 1 << 0
CRUD
Basic CRUD without count
public
mixed
CRUD
= self::GET | self::LIST | self::POST | self::PUT | self::DELETE
DEFAULT
Default routes: all CRUD operations enabled
public
mixed
DEFAULT
= self::COUNT | self::DELETE | self::DELETE_MULTIPLE | self::GET | self::LIST | self::PATCH | self::POST | self::PUT
DEFAULT_FLAG
public
mixed
DEFAULT_FLAG
= 'defaultFlag'
DELETE
Enable DELETE route
public
int
DELETE
= 1 << 1
DELETE_MULTIPLE
Enable DELETE with multiple IDs support
public
int
DELETE_MULTIPLE
= 1 << 2
FLAGS
The default list of flags.
public
mixed
FLAGS
= [self::COUNT, self::DELETE, self::DELETE_MULTIPLE, self::GET, self::LIST, self::PATCH, self::POST, self::PUT]
FLAGS_NAME
The list of flag's name.
public
mixed
FLAGS_NAME
= [self::COUNT => 'COUNT', self::DELETE => 'DELETE', self::DELETE_MULTIPLE => 'DELETE_MULTIPLE', self::GET => 'GET', self::LIST => 'LIST', self::PATCH => 'PATCH', self::POST => 'POST', self::PUT => 'PUT']
GET
Enable GET route
public
int
GET
= 1 << 3
HAS_COUNT
public
mixed
HAS_COUNT
= 'hasCount'
HAS_DELETE
public
mixed
HAS_DELETE
= 'hasDelete'
HAS_DELETE_MULTIPLE
public
mixed
HAS_DELETE_MULTIPLE
= 'hasDeleteMultiple'
HAS_GET
public
mixed
HAS_GET
= 'hasGet'
HAS_LIST
public
mixed
HAS_LIST
= 'hasList'
HAS_PATCH
public
mixed
HAS_PATCH
= 'hasPatch'
HAS_POST
public
mixed
HAS_POST
= 'hasPost'
HAS_PUT
public
mixed
HAS_PUT
= 'hasPut'
LIST
Enable LIST route
public
int
LIST
= 1 << 4
NONE
No routes enabled
public
int
NONE
= 0
PATCH
Enable PATCH route
public
int
PATCH
= 1 << 5
POST
Enable POST route
public
int
POST
= 1 << 6
PUT
Enable PUT route
public
int
PUT
= 1 << 7
READ_ONLY
Read-only routes (GET, LIST, COUNT)
public
mixed
READ_ONLY
= self::GET | self::LIST | self::COUNT
WRITE
Write routes (POST, PUT, PATCH, DELETE)
public
mixed
WRITE
= self::POST | self::PUT | self::PATCH | self::DELETE | self::DELETE_MULTIPLE
Methods
convertLegacyArray()
Converts legacy boolean array format to bitmask.
public
static convertLegacyArray([array<string|int, mixed> $init = [] ]) : int
Parameters
- $init : array<string|int, mixed> = []
-
Legacy initialization array
Return values
int —The resulting bitmask
describe()
Gets a human-readable description of the flags in a bitmask.
public
static describe(int $mask[, string $separator = ', ' ]) : string
Parameters
- $mask : int
-
The bitmask value to describe.
- $separator : string = ', '
-
The separator between the flag descriptions.
Tags
Return values
string —A comma-separated (by default) string of flag names.
getFlags()
Gets a list of all individual flags present in a bitmask.
public
static getFlags(int $mask) : array<string|int, int>
Parameters
- $mask : int
-
The bitmask value to decompose.
Tags
Return values
array<string|int, int> —An array of individual flag values present in the mask.
has()
Checks whether a specific flag is set in a bitmask.
public
static has(int $mask, int $flag) : bool
Parameters
- $mask : int
-
The bitmask value, potentially containing multiple flags combined with
|. - $flag : int
-
The specific flag to check for in the mask.
Tags
Return values
bool —Returns true if the given flag is present in the mask, false otherwise.
isValid()
Validates that a bitmask contains only valid RouteFlag values.
public
static isValid(int $mask) : bool
Parameters
- $mask : int
-
The bitmask value to validate.
Tags
Return values
bool —Returns true if the mask contains only valid flags, false otherwise.