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

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

ali-eltaweel/bitmask
====================

A simple bitmask library for PHP

1.0.0(10mo ago)0622PHPPHP ^8.1

Since Jun 20Pushed 10mo agoCompare

[ Source](https://github.com/ali-eltaweel/bitmask)[ Packagist](https://packagist.org/packages/ali-eltaweel/bitmask)[ RSS](/packages/ali-eltaweel-bitmask/feed)WikiDiscussions master Synced 1mo ago

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

Bitmask
=======

[](#bitmask)

**A simple bitmask library for PHP**

- [Bitmask](#bitmask)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Declaring Bitmask](#declaring-bitmask)
        - [Working with Bitmasks](#working-with-bitmasks)

---

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

[](#installation)

Install *bitmask* via Composer:

```
composer require ali-eltaweel/bitmask
```

Usage
-----

[](#usage)

### Declaring Bitmask

[](#declaring-bitmask)

```
use Bitmask\{ Annotations\Bit, Bitmask };

class JsonOptions extends Bitmask {

  #[Bit] const PRETTY_PRINT = JSON_PRETTY_PRINT;

  #[Bit] const UNESCAPED_SLASHES = JSON_UNESCAPED_SLASHES;

  #[Bit] const OBJECT_AS_ARRAY = JSON_OBJECT_AS_ARRAY;
}
```

Using the `#[Bit]` annotation with no arguments will result in the name of the constant being used as the bit's name. You can also pass a string to the annotation to specify a custom name for the bit:

```
use Bitmask\{ Annotations\Bit, Bitmask };

class JsonOptions extends Bitmask {

  #[Bit('pretty')] const PRETTY_PRINT = JSON_PRETTY_PRINT;

  #[Bit('forceArray')] const OBJECT_AS_ARRAY = JSON_OBJECT_AS_ARRAY;
}
```

### Working with Bitmasks

[](#working-with-bitmasks)

```
$jsonOptions = new JsonOptions(JsonOptions::PRETTY_PRINT);

$jsonOptions->has(JsonOptions::PRETTY_PRINT); // true
$jsonOptions->has(JsonOptions::UNESCAPED_SLASHES); // false

$jsonOptions = $jsonOptions->add(JsonOptions::UNESCAPED_SLASHES);
$jsonOptions->has(JsonOptions::UNESCAPED_SLASHES); // true

$jsonOptions = $jsonOptions->remove(JsonOptions::PRETTY_PRINT);
$jsonOptions->has('pretty'); // false

$jsonOptions = $jsonOptions->add('pretty|forceArray');
$jsonOptions->has('pretty'); // true
$jsonOptions->has(JsonOptions::OBJECT_AS_ARRAY); // true

$jsonOptions->toArray(); // [ 128 => 'pretty', 64 => 'UNESCAPED_SLASHES', 1 => 'forceArray' ]

$jsonOptions->toInt(); // 193
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance53

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

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

323d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7564e10ba11b25d8700726a92f669e38be2ff9191e8f6ccdfafc36678ffab2b8?d=identicon)[ali-eltaweel](/maintainers/ali-eltaweel)

---

Top Contributors

[![ali-eltaweel](https://avatars.githubusercontent.com/u/45892756?v=4)](https://github.com/ali-eltaweel "ali-eltaweel (2 commits)")

### Embed Badge

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

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

###  Alternatives

[marcelog/pami

Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented

415750.6k1](/packages/marcelog-pami)[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

395798.1k10](/packages/spicyweb-craft-neo)[geedmo/yamm3

Yet another megamenu for Bootstrap 3.x

1.2k12.6k](/packages/geedmo-yamm3)[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[fusonic/opengraph

PHP library for consuming and publishing Open Graph resources.

104373.0k4](/packages/fusonic-opengraph)[h4kuna/ares

Provides information about subjects by their identification number from the ARES database (in Czech Republic).

50394.6k2](/packages/h4kuna-ares)

PHPackages © 2026

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