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(12y ago)3964MITPHP

Since Oct 16Pushed 12y ago2 watchersCompare

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

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 52% 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

4390d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/112059?v=4)[Stephen Frank](/maintainers/stephenfrank)[@stephenfrank](https://github.com/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

[tonysm/rich-text-laravel

Integrates Trix content with Laravel

46891.8k1](/packages/tonysm-rich-text-laravel)[recca0120/laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using Vuerd.

36283.9k](/packages/recca0120-laravel-erd)[openeuropa/oe_content

OpenEuropa Drupal module that contains the EC corporate entity types.

13143.8k13](/packages/openeuropa-oe-content)

PHPackages © 2026

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