class Bitset implements IntegerRepresentation, StringRepresentation, ArrayRepresentation, ArrayAccess (View source)

Bit storage and manipulation

Constants

BIT_NONE

BIT_01

BIT_02

BIT_03

BIT_04

BIT_05

BIT_06

BIT_07

BIT_08

BYTE_01

BIT_09

BIT_10

BIT_11

BIT_12

BIT_13

BIT_14

BIT_15

BIT_16

BYTE_02

BIT_17

BIT_18

BIT_19

BIT_20

BIT_21

BIT_22

BIT_23

BIT_24

BYTE_03

BIT_25

BIT_26

BIT_27

BIT_28

BIT_29

BIT_30

BIT_31

BIT_32

BYTE_04

BIT_ALL

Methods

static number
getMaxIntegerValue(integer $bitCount, boolean $signed = false)

Get the maximum integer value that can be stored with the given number of bits.

__construct(integer|string|array $value = 0)

No description

boolean.
match(integer|IntegerRepresentation $bits, boolean $strict = false)

Indicates if the bitset contains at least one or all bit flags of another bit set.

add(integer|IntegerRepresentation $value)

Binary OR

remove(integer|IntegerRepresentation $value)

Remove bit flags

integer
getIntegerValue()

Get integer value of the bitset flags

string
__toString()

No description

array
getArrayCopy()

No description

string
getBinaryString(string $pad = '', number $padLength = 0, integer $padDirection = -1)

No description

offsetExists($offset)

No description

offsetGet($offset)

No description

offsetSet($offset, $value)

No description

offsetUnset($offset)

No description

Details

static number getMaxIntegerValue(integer $bitCount, boolean $signed = false)

Get the maximum integer value that can be stored with the given number of bits.

Parameters

integer $bitCount
boolean $signed

Return Value

number

__construct(integer|string|array $value = 0)

Parameters

integer|string|array $value

Exceptions

InvalidArgumentException

boolean. match(integer|IntegerRepresentation $bits, boolean $strict = false)

Indicates if the bitset contains at least one or all bit flags of another bit set.

Parameters

integer|IntegerRepresentation $bits Bit flags to test against Bitset instance value.
boolean $strict Whenever or not the instance value must match at least all of the bit flags of $bits.

Return Value

boolean.

Bitset add(integer|IntegerRepresentation $value)

Binary OR

Parameters

integer|IntegerRepresentation $value

Return Value

Bitset

Bitset remove(integer|IntegerRepresentation $value)

Remove bit flags

Parameters

integer|IntegerRepresentation $value

Return Value

Bitset

integer getIntegerValue()

Get integer value of the bitset flags

Return Value

integer Integer representation of the class instance

string __toString()

Return Value

string The string representation of the class instance

array getArrayCopy()

Return Value

array Array representation of the class instance

string getBinaryString(string $pad = '', number $padLength = 0, integer $padDirection = -1)

Parameters

string $pad Padding character
number $padLength Minimum number of characters of the output string.
integer $padDirection
  • ≤ 0: Left padded to reach $padLength characters
  • > 0: Right padded to reach $padLength characters

Return Value

string

offsetExists($offset)

Parameters

$offset

offsetGet($offset)

Parameters

$offset

offsetSet($offset, $value)

Parameters

$offset
$value

offsetUnset($offset)

Parameters

$offset