nekoos-pood/bitwise-flag

Utility for handling bitwise operations | Utilidad para el manejo de operaciones bit a bit

v0.1.0 2019-09-01 00:06 UTC

This package is auto-updated.

Last update: 2024-04-29 04:13:40 UTC


README

Install

composer require nekoos-pood/bitwise-flag

Usage

set

Flag up bit in current flag set

$flag = E_NOTICE;

BitwiseFlag::set($flags, E_RECOVERABLE_ERROR, true);

# $flag = E_NOTICE | E_RECOVERABLE_ERROR;

Flag down bit in current flag set

$flag = E_ALL;

BitwiseFlag::set($flags, E_NOTICE, false);

# $flag = E_ALL & ~E_NOTICE;

match

Check in the current set of flags if it is up bit

$flag = E_ALL & ~E_NOTICE;

$check1 = BitwiseFlag::match($flags, E_RECOVERABLE_ERROR);
$check2 = BitwiseFlag::match($flags, E_NOTICE);

# $check1 = true;
# $check2 = false;