Param uses ConstantsTrait
Centralized enumeration of parameter keys used across various parts of the application.
This class defines a large set of constants to avoid hard-coded string keys, enabling safer and more consistent parameter usage throughout your codebase.
Example usage:
use oihana\enums\Param;
$options = [
Param::LIMIT => 20,
Param::OFFSET => 0,
Param::ORDER => 'DESC',
Param::FILTER => ['status' => 'active'],
];
This enumeration can be used in:
- HTTP request parsers
- Configuration arrays
- Filtering and sorting logic
- CLI arguments
- Custom annotations or metadata
Optionally, you can group constants by context using a utility method like groupByPrefix()
.
Tags
Table of Contents
Constants
- ACTION = 'action'
- ACTIONS = 'actions'
- ACTIVABLE = 'activable'
- ACTIVE = 'active'
- AFTER = 'after'
- ALIAS = 'alias'
- ALL = 'all'
- ALT = 'alt'
- ALTER = 'alter'
- ALTERS = 'alters'
- ARGS = 'args'
- BASE_PATH = 'basePath'
- BATCH_SIZE = 'batchSize'
- BEFORE = 'before'
- BENCH = 'bench'
- BINDS = 'binds'
- BOOL = 'bool'
- CACHE = 'cache'
- CACHEABLE = 'cacheable'
- COLLECTION = 'collection'
- COMPARATOR = 'comparator'
- COMPRESS = 'compress'
- CONDITION = 'condition'
- CONDITIONS = 'conditions'
- CONFIG = 'config'
- CONTEXT = 'context'
- CONTROLLER = 'controller'
- CONTROLLERS = 'controllers'
- CUSTOM_RULES = 'customRules'
- DATE = 'date'
- DATE_FORMAT = 'dateFormat'
- DEBUG = 'debug'
- DEFAULT = 'default'
- DEFAULT_NOT_EQUALS = 'defaultNotEquals'
- DEFER_ASSIGNMENT = 'deferAssignment'
- DEFINITION = 'definition'
- DESCRIPTION = 'description'
- DESTROY = 'destroy'
- DIRECTION = 'direction'
- DIRECTORY = 'directory'
- DOC = 'doc'
- DOC_REF = 'docRef'
- DOCS = 'docs'
- DOCUMENT_KEY = 'documentKey'
- DOCUMENTS = 'documents'
- ENABLE = 'enable'
- ENABLED = 'enabled'
- ENCRYPT = 'encrypt'
- EXCLUDES = 'excludes'
- EXIST = 'exist'
- EXTENSIONS = 'extensions'
- EXTRA_QUERY = 'extraQuery'
- FACET = 'facet'
- FACETS = 'facets'
- FIELD = 'field'
- FIELDS = 'fields'
- FILE = 'file'
- FILTER = 'filter'
- FILTER_KEYS = 'filterKeys'
- FILTER_PATCH_AND_PUT_KEYS = 'filterPatchAndPutKeys'
- FILTER_PATCH_KEYS = 'filterPatchKeys'
- FILTER_POST_KEYS = 'filterPostKeys'
- FILTER_PUT_KEYS = 'filterPutKeys'
- FILTERABLE = 'filterable'
- FORCE_URL = 'forceUrl'
- FORMAT = 'format'
- FULL_PATH = 'fullPath'
- GROUP_BY = 'groupBy'
- HARVEST = 'harvest'
- HAS_TOTAL = 'hasTotal'
- HELP = 'help'
- HTML = 'html'
- I18N = 'i18n'
- ID = 'id'
- IDS = 'ids'
- INFLECTOR = 'inflector'
- INIT = 'init'
- INSERT = 'insert'
- INTERVAL = 'interval'
- INTERVAL_DEFAULT = 'interval_default'
- ITEMS = 'items'
- JOIN = 'join'
- JOINS = 'joins'
- JSON = 'json'
- JSON_OPTIONS = 'jsonOptions'
- KEY = 'key'
- KEY_LIST = 'keyList'
- LANG = 'lang'
- LAST = 'last'
- LAZY = 'lazy'
- LIMIT = 'limit'
- LIMIT_DEFAULT = 'limit_default'
- LIST = 'list'
- LOCATION = 'location'
- LOCATIONS = 'locations'
- LOCKABLE = 'lockable'
- LOGGABLE = 'loggable'
- LOGGER = 'logger'
- MARGIN = 'margin'
- MATCH = 'match'
- MAX_DEPTH = 'maxDepth'
- MAX_INTERVAL = 'maxInterval'
- MAX_LIMIT = 'maxLimit'
- MAX_RANGE = 'max_range'
- MEMCACHED = 'memcached'
- METHOD = 'method'
- METHODS = 'methods'
- MIN_LIMIT = 'minLimit'
- MIN_RANGE = 'min_range'
- MOCK = 'mock'
- MODEL = 'model'
- MODEL_ID = 'modelID'
- MODELS = 'models'
- NAME = 'name'
- NOT_EQUALS = 'notEquals'
- NUM = 'num'
- OBJECT = 'object'
- OFFSET = 'offset'
- OFFSET_DEFAULT = 'offset_default'
- OP = 'op'
- OPTIMIZED = 'optimized'
- OPTIONS = 'options'
- ORDER = 'order'
- OVERWRITE = 'overwrite'
- OWNER = 'owner'
- OWNER_KEY = 'ownerKey'
- OWNER_PATH = 'ownerPath'
- OWNERS = 'owners'
- PARAMS = 'params'
- PARAMS_STRATEGY = 'paramsStrategy'
- PASS_PHRASE = 'passphrase'
- PATH = 'path'
- PATTERN = 'pattern'
- PDO = 'pdo'
- POSITION = 'position'
- POST_INIT = 'postInit'
- PRE_INIT = 'preInit'
- PRECISION = 'precision'
- PREFIX = 'prefix'
- PRETTY_PRINT = 'pretty_print'
- PROPERTIES = 'properties'
- PROPERTY = 'property'
- PROPS = 'props'
- QUANTITY = 'quantity'
- QUERY = 'query'
- QUERY_BUILDER = 'queryBuilder'
- QUERY_FIELDS = 'queryFields'
- QUERY_ID = 'queryId'
- REDIRECTS = 'redirects'
- RELATIONS = 'relations'
- RETURN = 'return'
- REVERSE = 'reverse'
- ROUTE = 'route'
- RULE = 'rule'
- RULES = 'rules'
- SCHEMA = 'schema'
- SEARCH = 'search'
- SIDE = 'side'
- SILENT = 'silent'
- SINGLE = 'single'
- SKIN = 'skin'
- SKIN_DEFAULT = 'skinDefault'
- SKIN_FROM = 'skinFrom'
- SKIN_METHODS = 'skinMethods'
- SKIN_PREFIX = 'skin_'
- SKINS = 'skins'
- SKIP = 'skip'
- SORT = 'sort'
- SORT_DEFAULT = 'sortDefault'
- SORTABLE = 'sortable'
- STATUS = 'status'
- STATUS_NAME = 'statusName'
- STRICT = 'strict'
- TABLE = 'table'
- THINGS = 'things'
- TIMEZONE = 'timezone'
- TIMEZONE_DEFAULT = 'timezone_default'
- TOTAL = 'total'
- TYPE = 'type'
- UNIQUE = 'unique'
- UPDATE = 'update'
- URL = 'url'
- VAL = 'val'
- VALIDATOR = 'validator'
- VALUE = 'value'
- VALUES = 'values'
- VAR_NAME = 'varName'
- VERBOSE = 'verbose'
- WITH = 'with'
Properties
- $ALL : array<string|int, mixed>|null
- The list of all constants.
- $CONSTANTS : array<string|int, mixed>|null
- The flipped list of all constants.
Methods
- enums() : array<string|int, mixed>
- Returns an array of all constants in this enumeration.
- get() : mixed
- Returns a valid enumeration value or the default value.
- getAll() : array<string, string>
- Returns an array of constants in this class.
- getConstant() : string|array<string|int, string>|null
- Returns the constant name(s) associated with the given value.
- groupByPrefix() : array<string, mixed>
- Returns an associative array of constants whose names start with the given prefix.
- includes() : bool
- Checks if a given value is valid (exists as a constant in this class).
- resetCaches() : void
- Reset the internal cache of the static methods.
- validate() : void
- Validates if the passed-in value is a valid element in the current enum.
Constants
ACTION
public
mixed
ACTION
= 'action'
ACTIONS
public
mixed
ACTIONS
= 'actions'
ACTIVABLE
public
mixed
ACTIVABLE
= 'activable'
ACTIVE
public
mixed
ACTIVE
= 'active'
AFTER
public
mixed
AFTER
= 'after'
ALIAS
public
mixed
ALIAS
= 'alias'
ALL
public
mixed
ALL
= 'all'
ALT
public
mixed
ALT
= 'alt'
ALTER
public
mixed
ALTER
= 'alter'
ALTERS
public
mixed
ALTERS
= 'alters'
ARGS
public
mixed
ARGS
= 'args'
BASE_PATH
public
mixed
BASE_PATH
= 'basePath'
BATCH_SIZE
public
mixed
BATCH_SIZE
= 'batchSize'
BEFORE
public
mixed
BEFORE
= 'before'
BENCH
public
mixed
BENCH
= 'bench'
BINDS
public
mixed
BINDS
= 'binds'
BOOL
public
mixed
BOOL
= 'bool'
CACHE
public
mixed
CACHE
= 'cache'
CACHEABLE
public
mixed
CACHEABLE
= 'cacheable'
COLLECTION
public
mixed
COLLECTION
= 'collection'
COMPARATOR
public
mixed
COMPARATOR
= 'comparator'
COMPRESS
public
mixed
COMPRESS
= 'compress'
CONDITION
public
mixed
CONDITION
= 'condition'
CONDITIONS
public
mixed
CONDITIONS
= 'conditions'
CONFIG
public
mixed
CONFIG
= 'config'
CONTEXT
public
mixed
CONTEXT
= 'context'
CONTROLLER
public
mixed
CONTROLLER
= 'controller'
CONTROLLERS
public
mixed
CONTROLLERS
= 'controllers'
CUSTOM_RULES
public
mixed
CUSTOM_RULES
= 'customRules'
DATE
public
mixed
DATE
= 'date'
DATE_FORMAT
public
mixed
DATE_FORMAT
= 'dateFormat'
DEBUG
public
mixed
DEBUG
= 'debug'
DEFAULT
public
mixed
DEFAULT
= 'default'
DEFAULT_NOT_EQUALS
public
mixed
DEFAULT_NOT_EQUALS
= 'defaultNotEquals'
DEFER_ASSIGNMENT
public
mixed
DEFER_ASSIGNMENT
= 'deferAssignment'
DEFINITION
public
mixed
DEFINITION
= 'definition'
DESCRIPTION
public
mixed
DESCRIPTION
= 'description'
DESTROY
public
mixed
DESTROY
= 'destroy'
DIRECTION
public
mixed
DIRECTION
= 'direction'
DIRECTORY
public
mixed
DIRECTORY
= 'directory'
DOC
public
mixed
DOC
= 'doc'
DOC_REF
public
mixed
DOC_REF
= 'docRef'
DOCS
public
mixed
DOCS
= 'docs'
DOCUMENT_KEY
public
mixed
DOCUMENT_KEY
= 'documentKey'
DOCUMENTS
public
mixed
DOCUMENTS
= 'documents'
ENABLE
public
mixed
ENABLE
= 'enable'
ENABLED
public
mixed
ENABLED
= 'enabled'
ENCRYPT
public
mixed
ENCRYPT
= 'encrypt'
EXCLUDES
public
mixed
EXCLUDES
= 'excludes'
EXIST
public
mixed
EXIST
= 'exist'
EXTENSIONS
public
mixed
EXTENSIONS
= 'extensions'
EXTRA_QUERY
public
mixed
EXTRA_QUERY
= 'extraQuery'
FACET
public
mixed
FACET
= 'facet'
FACETS
public
mixed
FACETS
= 'facets'
FIELD
public
mixed
FIELD
= 'field'
FIELDS
public
mixed
FIELDS
= 'fields'
FILE
public
mixed
FILE
= 'file'
FILTER
public
mixed
FILTER
= 'filter'
FILTER_KEYS
public
mixed
FILTER_KEYS
= 'filterKeys'
FILTER_PATCH_AND_PUT_KEYS
public
mixed
FILTER_PATCH_AND_PUT_KEYS
= 'filterPatchAndPutKeys'
FILTER_PATCH_KEYS
public
mixed
FILTER_PATCH_KEYS
= 'filterPatchKeys'
FILTER_POST_KEYS
public
mixed
FILTER_POST_KEYS
= 'filterPostKeys'
FILTER_PUT_KEYS
public
mixed
FILTER_PUT_KEYS
= 'filterPutKeys'
FILTERABLE
public
mixed
FILTERABLE
= 'filterable'
FORCE_URL
public
mixed
FORCE_URL
= 'forceUrl'
FORMAT
public
mixed
FORMAT
= 'format'
FULL_PATH
public
mixed
FULL_PATH
= 'fullPath'
GROUP_BY
public
mixed
GROUP_BY
= 'groupBy'
HARVEST
public
mixed
HARVEST
= 'harvest'
HAS_TOTAL
public
mixed
HAS_TOTAL
= 'hasTotal'
HELP
public
mixed
HELP
= 'help'
HTML
public
mixed
HTML
= 'html'
I18N
public
mixed
I18N
= 'i18n'
ID
public
mixed
ID
= 'id'
IDS
public
mixed
IDS
= 'ids'
INFLECTOR
public
mixed
INFLECTOR
= 'inflector'
INIT
public
mixed
INIT
= 'init'
INSERT
public
mixed
INSERT
= 'insert'
INTERVAL
public
mixed
INTERVAL
= 'interval'
INTERVAL_DEFAULT
public
mixed
INTERVAL_DEFAULT
= 'interval_default'
ITEMS
public
mixed
ITEMS
= 'items'
JOIN
public
mixed
JOIN
= 'join'
JOINS
public
mixed
JOINS
= 'joins'
JSON
public
mixed
JSON
= 'json'
JSON_OPTIONS
public
mixed
JSON_OPTIONS
= 'jsonOptions'
KEY
public
mixed
KEY
= 'key'
KEY_LIST
public
mixed
KEY_LIST
= 'keyList'
LANG
public
mixed
LANG
= 'lang'
LAST
public
mixed
LAST
= 'last'
LAZY
public
mixed
LAZY
= 'lazy'
LIMIT
public
mixed
LIMIT
= 'limit'
LIMIT_DEFAULT
public
mixed
LIMIT_DEFAULT
= 'limit_default'
LIST
public
mixed
LIST
= 'list'
LOCATION
public
mixed
LOCATION
= 'location'
LOCATIONS
public
mixed
LOCATIONS
= 'locations'
LOCKABLE
public
mixed
LOCKABLE
= 'lockable'
LOGGABLE
public
mixed
LOGGABLE
= 'loggable'
LOGGER
public
mixed
LOGGER
= 'logger'
MARGIN
public
mixed
MARGIN
= 'margin'
MATCH
public
mixed
MATCH
= 'match'
MAX_DEPTH
public
mixed
MAX_DEPTH
= 'maxDepth'
MAX_INTERVAL
public
mixed
MAX_INTERVAL
= 'maxInterval'
MAX_LIMIT
public
mixed
MAX_LIMIT
= 'maxLimit'
MAX_RANGE
public
mixed
MAX_RANGE
= 'max_range'
MEMCACHED
public
mixed
MEMCACHED
= 'memcached'
METHOD
public
mixed
METHOD
= 'method'
METHODS
public
mixed
METHODS
= 'methods'
MIN_LIMIT
public
mixed
MIN_LIMIT
= 'minLimit'
MIN_RANGE
public
mixed
MIN_RANGE
= 'min_range'
MOCK
public
mixed
MOCK
= 'mock'
MODEL
public
mixed
MODEL
= 'model'
MODEL_ID
public
mixed
MODEL_ID
= 'modelID'
MODELS
public
mixed
MODELS
= 'models'
NAME
public
mixed
NAME
= 'name'
NOT_EQUALS
public
mixed
NOT_EQUALS
= 'notEquals'
NUM
public
mixed
NUM
= 'num'
OBJECT
public
mixed
OBJECT
= 'object'
OFFSET
public
mixed
OFFSET
= 'offset'
OFFSET_DEFAULT
public
mixed
OFFSET_DEFAULT
= 'offset_default'
OP
public
mixed
OP
= 'op'
OPTIMIZED
public
mixed
OPTIMIZED
= 'optimized'
OPTIONS
public
mixed
OPTIONS
= 'options'
ORDER
public
mixed
ORDER
= 'order'
OVERWRITE
public
mixed
OVERWRITE
= 'overwrite'
OWNER
public
mixed
OWNER
= 'owner'
OWNER_KEY
public
mixed
OWNER_KEY
= 'ownerKey'
OWNER_PATH
public
mixed
OWNER_PATH
= 'ownerPath'
OWNERS
public
mixed
OWNERS
= 'owners'
PARAMS
public
mixed
PARAMS
= 'params'
PARAMS_STRATEGY
public
mixed
PARAMS_STRATEGY
= 'paramsStrategy'
PASS_PHRASE
public
mixed
PASS_PHRASE
= 'passphrase'
PATH
public
mixed
PATH
= 'path'
PATTERN
public
mixed
PATTERN
= 'pattern'
PDO
public
mixed
PDO
= 'pdo'
POSITION
public
mixed
POSITION
= 'position'
POST_INIT
public
mixed
POST_INIT
= 'postInit'
PRE_INIT
public
mixed
PRE_INIT
= 'preInit'
PRECISION
public
mixed
PRECISION
= 'precision'
PREFIX
public
mixed
PREFIX
= 'prefix'
PRETTY_PRINT
public
mixed
PRETTY_PRINT
= 'pretty_print'
PROPERTIES
public
mixed
PROPERTIES
= 'properties'
PROPERTY
public
mixed
PROPERTY
= 'property'
PROPS
public
mixed
PROPS
= 'props'
QUANTITY
public
mixed
QUANTITY
= 'quantity'
QUERY
public
mixed
QUERY
= 'query'
QUERY_BUILDER
public
mixed
QUERY_BUILDER
= 'queryBuilder'
QUERY_FIELDS
public
mixed
QUERY_FIELDS
= 'queryFields'
QUERY_ID
public
mixed
QUERY_ID
= 'queryId'
REDIRECTS
public
mixed
REDIRECTS
= 'redirects'
RELATIONS
public
mixed
RELATIONS
= 'relations'
RETURN
public
mixed
RETURN
= 'return'
REVERSE
public
mixed
REVERSE
= 'reverse'
ROUTE
public
mixed
ROUTE
= 'route'
RULE
public
mixed
RULE
= 'rule'
RULES
public
mixed
RULES
= 'rules'
SCHEMA
public
mixed
SCHEMA
= 'schema'
SEARCH
public
mixed
SEARCH
= 'search'
SIDE
public
mixed
SIDE
= 'side'
SILENT
public
mixed
SILENT
= 'silent'
SINGLE
public
mixed
SINGLE
= 'single'
SKIN
public
mixed
SKIN
= 'skin'
SKIN_DEFAULT
public
mixed
SKIN_DEFAULT
= 'skinDefault'
SKIN_FROM
public
mixed
SKIN_FROM
= 'skinFrom'
SKIN_METHODS
public
mixed
SKIN_METHODS
= 'skinMethods'
SKIN_PREFIX
public
mixed
SKIN_PREFIX
= 'skin_'
SKINS
public
mixed
SKINS
= 'skins'
SKIP
public
mixed
SKIP
= 'skip'
SORT
public
mixed
SORT
= 'sort'
SORT_DEFAULT
public
mixed
SORT_DEFAULT
= 'sortDefault'
SORTABLE
public
mixed
SORTABLE
= 'sortable'
STATUS
public
mixed
STATUS
= 'status'
STATUS_NAME
public
mixed
STATUS_NAME
= 'statusName'
STRICT
public
mixed
STRICT
= 'strict'
TABLE
public
mixed
TABLE
= 'table'
THINGS
public
mixed
THINGS
= 'things'
TIMEZONE
public
mixed
TIMEZONE
= 'timezone'
TIMEZONE_DEFAULT
public
mixed
TIMEZONE_DEFAULT
= 'timezone_default'
TOTAL
public
mixed
TOTAL
= 'total'
TYPE
public
mixed
TYPE
= 'type'
UNIQUE
public
mixed
UNIQUE
= 'unique'
UPDATE
public
mixed
UPDATE
= 'update'
URL
public
mixed
URL
= 'url'
VAL
public
mixed
VAL
= 'val'
VALIDATOR
public
mixed
VALIDATOR
= 'validator'
VALUE
public
mixed
VALUE
= 'value'
VALUES
public
mixed
VALUES
= 'values'
VAR_NAME
public
mixed
VAR_NAME
= 'varName'
VERBOSE
public
mixed
VERBOSE
= 'verbose'
WITH
public
mixed
WITH
= 'with'
Properties
$ALL
The list of all constants.
protected
static array<string|int, mixed>|null
$ALL
= null
$CONSTANTS
The flipped list of all constants.
protected
static array<string|int, mixed>|null
$CONSTANTS
= null
Methods
enums()
Returns an array of all constants in this enumeration.
public
static enums([int $flags = SORT_STRING ]) : array<string|int, mixed>
Parameters
- $flags : int = SORT_STRING
-
The optional second parameter flags may be used to modify the comparison behavior using these values: Comparison type flags:
- SORT_REGULAR - compare items normally (don't change types)
- SORT_NUMERIC - compare items numerically
- SORT_STRING - compare items as strings
- SORT_LOCALE_STRING - compare items as strings, based on the current locale.
Return values
array<string|int, mixed>get()
Returns a valid enumeration value or the default value.
public
static get(mixed $value[, mixed|null $default = null ]) : mixed
Parameters
- $value : mixed
- $default : mixed|null = null
getAll()
Returns an array of constants in this class.
public
static getAll() : array<string, string>
Return values
array<string, string>getConstant()
Returns the constant name(s) associated with the given value.
public
static getConstant(string $value[, string|array<string|int, string>|null $separator = null ]) : string|array<string|int, string>|null
This method searches the class constants for one or multiple constants whose value matches (or contains) the provided value.
If the constant values are strings containing multiple parts separated by one or more separators, it splits them accordingly before matching.
The method returns:
- a string with the constant name if exactly one constant matches,
- an array of constant names if multiple constants share the same value,
- or null if no constant matches the given value.
The internal cache is used to optimize repeated lookups.
Parameters
- $value : string
-
The value to search for among the constants.
- $separator : string|array<string|int, string>|null = null
-
Optional separator(s) to split constant values before matching.
- If null, no splitting is performed.
- If a string, it is used as the delimiter.
- If an array of strings, each separator is applied iteratively.
Return values
string|array<string|int, string>|null —The constant name(s) matching the value, or null if none found.
groupByPrefix()
Returns an associative array of constants whose names start with the given prefix.
public
static groupByPrefix(string $prefix) : array<string, mixed>
This is useful for grouping related parameters based on naming convention, such as all constants starting with "filter", "json", or "skin".
The returned array preserves constant names as keys and their corresponding values.
Example:
Param::groupByPrefix('FILTER_');
// [
// 'FILTER' => 'filter',
// 'FILTER_KEYS' => 'filterKeys',
// 'FILTER_POST_KEYS' => 'filterPostKeys',
// ...
// ]
Parameters
- $prefix : string
-
The prefix to match against constant names.
Return values
array<string, mixed> —An associative array of matching constant names and their values.
includes()
Checks if a given value is valid (exists as a constant in this class).
public
static includes(mixed $value[, bool $strict = false ][, string|null $separator = null ]) : bool
Parameters
- $value : mixed
- $strict : bool = false
-
[optional]
If the third parameter strict is set to true then the in_array function will also check the types of the needle in the haystack.
- $separator : string|null = null
-
The optional string separator if the constant value contains multiple values in a single string expression.
Return values
bool —True if the value exist, False otherwise.
resetCaches()
Reset the internal cache of the static methods.
public
static resetCaches() : void
validate()
Validates if the passed-in value is a valid element in the current enum.
public
static validate(mixed $value[, bool $strict = true ][, string|null $separator = null ]) : void
Parameters
- $value : mixed
- $strict : bool = true
-
[optional]
If the third parameter strict is set to true then the in_array function will also check the types of the needle in the haystack.
- $separator : string|null = null
-
The optional string separator if the constant value contains multiple values in a single string expression.