PHPackages                             flow/bitwiser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. flow/bitwiser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flow/bitwiser
=============

Helper class for managing bitwise flags

0.1.3(11y ago)3963MITPHP

Since Oct 16Pushed 11y ago2 watchersCompare

[ Source](https://github.com/FlowCommunications/Bitwiser)[ Packagist](https://packagist.org/packages/flow/bitwiser)[ RSS](/packages/flow-bitwiser/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Bitwiser
========

[](#bitwiser)

**Bitwiser** is a utility class to help managing bitwise flags.

Bitwise flags are a convenient way to store multiple true/false values (flags) in a single integer based database column. The number of bitwise flags are *however* limited to the maximum value of an integer of the system (which is 64 on a 64bit system or 32 on a 32bit system).

Example usage
-------------

[](#example-usage)

Create a class that extends `AbstractBitwiser` and declare the flags as class constants.

```
class PermissionsBitwiser extends AbstractBitwiser
{
    const CAN_EDIT_POSTS = 0;
    const CAN_DELETE_POSTS = 1;
    const CAN_CREATE_USERS = 2;
}
```

Initialize the class with a starting state and callback

```
$state = 0; // this value is passed by reference

$permissions = new PermissionsBitwiser($state, function (AbstractBitwiser $bitwiser) {
	echo $bitwiser->getState();
});

$permissions->add(PermissionsBitwiser::CAN_EDIT_POSTS); // echoes 1
$permissions->add(PermissionsBitwiser::CAN_DELETE_POSTS); // echoes 3
$permissions->add(PermissionsBitwiser::CAN_CREATE_USERS); // echoes 7
$permissions->remove(PermissionsBitwiser::CAN_DELETE_POSTS); // echoes 5

$permissions->getState(); // int(5)
$permissions->has(PermissionsBitwiser::CAN_EDIT_POSTS); // true
$permissions->has(PermissionsBitwiser::CAN_DELETE_POSTS); // false
```

Example usage with ORM (eg. Laravel Eloquent) for persisitence
--------------------------------------------------------------

[](#example-usage-with-orm-eg-laravel-eloquent-for-persisitence)

The end goal is to persist the integer value to a database column while maintaining a clean OO method of updating the value.

```
class User extends Model
{
    public function getPermissionsAttribute()
    {
        $state = $this->attributes['permissions']; // Don't pass this by reference
        $self = $this;
        return new PermissionsBitwiser($state, function ($bitwiser) use ($self) {
            $self->permissions = $bitwiser->getState();
        });
    }
}

$user = new User;

$user->permissions->add(PermissionsBitwiser::CAN_CREATE_USERS);

$user->save();

$user->permissions->has(PermissionsBitwiser::CAN_DELETE_POSTS); // false
$user->permissions->has(PermissionsBitwiser::CAN_CREATE_USERS); // true. etc
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~125 days

Total

3

Last Release

4343d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82c5de45afd4f3157345b31b87f2953732fd094c7a002f2e968285724d35809c?d=identicon)[stephenfrank](/maintainers/stephenfrank)

---

Top Contributors

[![stephenfrank](https://avatars.githubusercontent.com/u/112059?v=4)](https://github.com/stephenfrank "stephenfrank (8 commits)")

### Embed Badge

![Health badge](/badges/flow-bitwiser/health.svg)

```
[![Health](https://phpackages.com/badges/flow-bitwiser/health.svg)](https://phpackages.com/packages/flow-bitwiser)
```

###  Alternatives

[willdurand/geocoder

Common files for PHP Geocoder

17435.7M159](/packages/willdurand-geocoder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
