CSBooleanUtils
in package
Collection of various convenience methods regarding boolean or bit operations
This class offers a set of methods that will be helpful to work with bits and booleans in PHP.
Tags
Table of Contents
- addFlag() : int
- Add a bit flag to a given value. If the value already has the bit set, the value will not be modified.
- hasFlag() : bool
- Checks if a bit flag is set for a given value.
- removeFlag() : int
- Removes a bit flag from a given value. If the value did not have the flag set in the first place, the value will not be modified.
Methods
addFlag()
Add a bit flag to a given value. If the value already has the bit set, the value will not be modified.
public
static addFlag(int $iValue, int|array<string|int, int> $mFlagToAdd) : int
Parameters
- $iValue : int
-
The value to which the flag has to be added
- $mFlagToAdd : int|array<string|int, int>
-
The bit flag to be added to the value. An array if more than one flag needs to be added
Tags
Return values
int —The new value
hasFlag()
Checks if a bit flag is set for a given value.
public
static hasFlag(int $iValue, int|array<string|int, int> $mFlagToCheck) : bool
Parameters
- $iValue : int
-
The value to be checked
- $mFlagToCheck : int|array<string|int, int>
-
The bit to be checked if it is set in the value. An array to check multiple flags at once.
Tags
Return values
bool —TRUE if the flag is (or ALL flags are) contained in the value
removeFlag()
Removes a bit flag from a given value. If the value did not have the flag set in the first place, the value will not be modified.
public
static removeFlag(int $iValue, int|array<string|int, int> $mFlagToRemove) : int
Parameters
- $iValue : int
-
The value to which the flag has to be removed
- $mFlagToRemove : int|array<string|int, int>
-
The bit flag to be removed from the value. An array if more than one flag needs to be removed
Tags
Return values
int —The new value
