Loading repository data…
Loading repository data…
vinicciusguedes / repository
Pacote para facilitar a manipulação de números usando operações bitwise no Laravel. Ideal para casos de uso como gerenciamento de permissões e flags, fornecendo funções para verificar, ativar, desativar e inverter bits de forma simples e eficiente.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Pacote para facilitar a manipulação de números usando operações bitwise no Laravel. Ideal para casos de uso como gerenciamento de permissões e flags, fornecendo funções para verificar, ativar, desativar e inverter bits de forma simples e eficiente.
Você pode instalar o pacote através do Composer:
composer require vinicciusguedes/laravel-bitwise
Esta tabela mostra as versões do Laravel e suas versões compatíveis com o PHP.
| Laravel | PHP |
|---|---|
| 12.* | 8.4, 8.3, 8.2 |
| 11.* | 8.4, 8.3, 8.2 |
| 10.* | 8.4, 8.3, 8.2, 8.1, 8.0 |
| 9.* | 8.4, 8.3, 8.2, 8.1, 8.0 |
| 8.* | 8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3 |
| 7.* | 8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2 |
| 6.* | 8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2 |
A tabela de compatibilidade pode ser ajustada de acordo com novas atualizações de versões do PHP ou Laravel.
O pacote oferece funções úteis para trabalhar com operações bitwise, como:
✅ addBit(int $currentValue, int $bit): int
$currentValue = 5; // 0101 em binário
$bitToAdd = 2; // 0010 em binário
$newValue = Bitwise::addBit($currentValue, $bitToAdd); // 7 (0111 em binário)
✅ addBits(int $currentValue, int $bit): int
$currentValue = 5; // 0101 em binário
$bitToAdd = [2, 4];
$newValue = Bitwise::addBits($currentValue, $bitToAdd); // 7 (0111 em binário)
✅ removeBit(int $currentValue, int $bit): int
$currentValue = 7; // 0111 em binário
$bitToRemove = 2; // 0010 em binário
$newValue = Bitwise::removeBit($currentValue, $bitToRemove); // 5 (0101 em binário)
✅ removeBits(int $currentValue, array $bits): int
$currentValue = 15; // 1111 em binário
$bitToRemove = [1, 4];
$newValue = Bitwise::removeBits($currentValue, $bitToRemove); // 10 (1010 em binário)
✅ hasBit(int $currentValue, int $bit): bool
$currentValue = 5; // 0101 em binário
$bitToCheck = 4; // 0100 em binário
$isActive = Bitwise::hasBit($currentValue, $bitToCheck); // true
✅ hasAllBits(int $bitValue, array $bits): bool
$currentValue = 15; // 1111 em binário
$bitsArray = [1, 2, 4];
$allBitsActive = Bitwise::hasAllBits($currentValue, $bitsArray); // true
✅ getActiveBits(int $value, bool $key_type = true, bool $order = true): array
$value = 7; // 0111 em binário
$activeBits = Bitwise::getActiveBits($value); // [1, 2, 4]
✅ sumActiveBits(array $bits): int
$bits = [1, 2, 4];
$sum = Bitwise::sumActiveBits($bits); // 7
✅ addBitInArray(array $array, int $bit, bool $key_type = true, bool $order = true): array
$bitsArray = [1, 2];
$newArray = Bitwise::addBitInArray($bitsArray, 4); // [1, 2, 4]
✅ hasBitsInArray(int $bitValue, array $bits): array
$bitValue = 7; // 0111 em binário
$bitsToCheck = [1, 2, 4];
$results = Bitwise::hasBitsInArray($bitValue, $bitsToCheck);
// [1 => true, 2 => true, 4 => true]
✅ sortBitsByKey(array $bits): array
$bitsToCheck = [4 => 4, 2 => 2, 1 => 1];
$results = Bitwise::sortBitsByKey($bitsToCheck);
// [1 => 1, 2 => 2, 4 => 4]
✅ sortBitsByValue(array $bits): array
$bitsToCheck = [4,2,1];
$results = Bitwise::sortBitsByValue($bitsToCheck);
// [2 => 1, 1 => 2, 0 => 4]
✅ toBinaryString(int $value): string
$number = 5;
$results = Bitwise::toBinaryString($number);
// 101
✅ fromBinary(string $value): int
$number = "101";
$results = Bitwise::fromBinary($number);
// 5
✅ function invertBit(int $value): int
$bit = 1;
$results = Bitwise::invertBit($bit);
// 0
Desenvolvedor: Viníccius Guedes