PHPackages                             mfonte/bitmask - 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. mfonte/bitmask

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

mfonte/bitmask
==============

Bitmask class helps you to use all might of bit masks and don't care about what bitwise operations are. It represents a high-level abstraction that looks like simple and manageable object and behaves like collection.

v1.0(3y ago)020MITPHPPHP &gt;=7.0

Since Feb 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mauriziofonte/bitmask)[ Packagist](https://packagist.org/packages/mfonte/bitmask)[ Docs](https://github.com/mauriziofonte/bitmask)[ RSS](/packages/mfonte-bitmask/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

BitMask
=======

[](#bitmask)

Bitmask class helps you to use all might of bit masks and don't care about what bitwise operations are. It represents a high-level abstraction that looks like simple and manageable object and behaves like collection.

Installation
------------

[](#installation)

Add the following dependency to your composer.json file.

```
{
    "require": {
        "mfonte/bitmask": "^1.0"
    }
}
```

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

[](#example-usage)

For example we have User class that can have different roles.

```
use Mfonte\Bit\Mask;

class User
{
    const ROLE_ADMIN = Mask::FLAG_1;
    const ROLE_MANAGER = Mask::FLAG_2;
    const ROLE_CUSTOMER = Mask::FLAG_3;

    /**
     * @var Mask
     */
    private $roles;

    public function __construct()
    {
        $this->roles = new Mask();
    }

    public function becomeAdmin()
    {
        $this->roles->add(self::ROLE_ADMIN);
    }

    public function isAdmin()
    {
        return $this->roles->has(self::ROLE_ADMIN);
    }

    ...

    public function isCustomer()
    {
        return $this->roles->has(self::ROLE_CUSTOMER);
    }

    ...
}
```

Now we are able to create a user.

```
$user = new User();

$user->becomeAdmin(); // User now has admin role
$user->becomeAdmin(); // Throws MaskException because role has been already set
                      // and mask is in strict mode

$user->isAdmin(); // Returns true
$user->isCustomer(); // Returns false
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

1185d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7733524e324e4a6f68d80bad3cfc5737cda0bfb072154210de09c7c2820d070c?d=identicon)[mauriziofonte](/maintainers/mauriziofonte)

---

Top Contributors

[![mauriziofonte](https://avatars.githubusercontent.com/u/1758841?v=4)](https://github.com/mauriziofonte "mauriziofonte (3 commits)")

---

Tags

bitmaskbitwise

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mfonte-bitmask/health.svg)

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

###  Alternatives

[yaroslavche/bitmask

BitMask, EnumBitMask

3453.7k1](/packages/yaroslavche-bitmask)[fanmade/laravel-bitwise-trait

Simple trait to use bitwise operators on any class

1570.7k](/packages/fanmade-laravel-bitwise-trait)

PHPackages © 2026

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