Oihana PHP

BitFlagTrait

Trait providing common methods for bitmask flag enumerations.

Classes using this trait MUST define the following constants:

  • NONE (int)
  • ALL (int)
  • FLAGS (array)
  • FLAGS_NAME (array<int, string>)
Tags
author

Marc Alcaraz

since
1.0.8

Table of Contents

Methods

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 flags.

Methods

describe()

Gets a human-readable description of the flags in a bitmask.

public static describe(int $mask[, string $separator = ', ' ]) : string
Parameters
$mask : int
$separator : string = ', '
Return values
string

getFlags()

Gets a list of all individual flags present in a bitmask.

public static getFlags(int $mask) : array<string|int, int>
Parameters
$mask : int
Return values
array<string|int, int>

has()

Checks whether a specific flag is set in a bitmask.

public static has(int $mask, int $flag) : bool
Parameters
$mask : int
$flag : int
Return values
bool

isValid()

Validates that a bitmask contains only valid flags.

public static isValid(int $mask) : bool
Parameters
$mask : int
Return values
bool

        
On this page

Search results