PHPackages                             asolomatin/php-big-bit-mask - 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. asolomatin/php-big-bit-mask

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

asolomatin/php-big-bit-mask
===========================

Bitmask compatible with JavaScript big-bit-mask - the bitmask serializable into a base64-like, url-safe string.

1.0.2(5y ago)11.3k[1 PRs](https://github.com/ASolomatin/php-big-bit-mask/pulls)MITPHPPHP &gt;=7.3.0

Since Jul 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ASolomatin/php-big-bit-mask)[ Packagist](https://packagist.org/packages/asolomatin/php-big-bit-mask)[ Docs](https://github.com/ASolomatin/php-big-bit-mask)[ RSS](/packages/asolomatin-php-big-bit-mask/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

PHP big bit mask
================

[](#php-big-bit-mask)

[![Packagist](https://camo.githubusercontent.com/1f211402a2eba95f59c943fec8c2e74c03bc1a5bfb056b7b698d2e753d0d0f50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61736f6c6f6d6174696e2f7068702d6269672d6269742d6d61736b2e737667)](https://packagist.org/packages/asolomatin/php-big-bit-mask)[![Packagist downloads](https://camo.githubusercontent.com/7503268bed4caa7ce026093cca36c883353ff863885428d629e564499642e43c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61736f6c6f6d6174696e2f7068702d6269672d6269742d6d61736b2e737667)](https://packagist.org/packages/asolomatin/php-big-bit-mask)[![Travis-CI](https://camo.githubusercontent.com/a0778c9c24cbfda1b5248fc463ea69d66b6a39fecda927904d818b5854af5149/68747470733a2f2f7472617669732d63692e636f6d2f41536f6c6f6d6174696e2f7068702d6269672d6269742d6d61736b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/github/ASolomatin/php-big-bit-mask)[![Coverage Status](https://camo.githubusercontent.com/7fd1e9942f9117056d3e28da43f6f3ea44eeb44b99012977e23f87dc4e99d477/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f41536f6c6f6d6174696e2f7068702d6269672d6269742d6d61736b2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ASolomatin/php-big-bit-mask?branch=master)[![GitHub](https://camo.githubusercontent.com/f4a663227ce98ec00ffa5786d28981e3d8182e65d403741605e7ce8b87b93add/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f41536f6c6f6d6174696e2f7068702d6269672d6269742d6d61736b)](https://github.com/ASolomatin/php-big-bit-mask/blob/master/LICENSE)

---

When bits is not enough ...

This library implements an fully compatible PHP version of [big-bit-mask](https://github.com/ASolomatin/big-bit-mask) - the bitmask serializable into a base64-like, url-safe string.

Other platform compatibility
----------------------------

[](#other-platform-compatibility)

PlatformRepositoryPackageJavaScript / TypeScript[big-bit-mask](https://github.com/ASolomatin/big-bit-mask)[NPM](https://www.npmjs.com/package/big-bit-mask).NET[BigBitMask.NET](https://github.com/ASolomatin/BigBitMask.NET)[NuGet](https://www.nuget.org/packages/BigBitMask.NET/)Install
-------

[](#install)

```
> composer require asolomatin/php-big-bit-mask
```

Usage
-----

[](#usage)

### Namespace

[](#namespace)

```
use asolomatin\BigBitMask\BitMask;
```

### What next?

[](#what-next)

Now we can create new empty bitmask

```
$bitmask = new BitMask();
```

or load it from string

```
$bitmask = new BitMask("CE3fG_gE-56");

//Let's see what inside now
$content = "";
for ($i = 0; $i < 11 * 6; $i++) { // Each character contains 6 bits, as in base64
    $content .= $bitmask[$i] ? "1" : "0";
}
echo $content.PHP_EOL;
```

output: `010000001000111011111110011000111111000001001000011111100111010111`

Then we can change some bits and get back our string representation

```
$bitmask[65] = false;
$bitmask[64] = false;
$bitmask[63] = false;
$bitmask[61] = false;

$bitmask[19] = false;
$bitmask[5] = true;

echo strval($bitmask).PHP_EOL;
```

output: `iE3dG_gE-5`

#### But what if I want to have a named flags?

[](#but-what-if-i-want-to-have-a-named-flags)

You can extend BitMask class with your model:

```
class MyCoolCheckboxes extends BitMask
{
    const CHECKBOX_0 = 0;
    const CHECKBOX_1 = 1;
    const CHECKBOX_2 = 2;
    const CHECKBOX_3 = 3;
    const CHECKBOX_4 = 4;
    const CHECKBOX_5 = 5;
    const CHECKBOX_6 = 6;
    const CHECKBOX_7 = 7;
    const CHECKBOX_8 = 8;
    const CHECKBOX_9 = 9;

    // Some magic
    public function __set(string $name, bool $value) { call_user_func([$this, "set".ucfirst($name)], $value); }
    public function __get(string $name): bool { return call_user_func([$this, "set".ucfirst($name)]); }

    public function getCheckbox0(): bool { return $this[self::CHECKBOX_0]; }
    public function setCheckbox0(bool $value) { $this[self::CHECKBOX_0] = $value; }

    public function getCheckbox1(): bool { return $this[self::CHECKBOX_1]; }
    public function setCheckbox1(bool $value) { $this[self::CHECKBOX_1] = $value; }

    public function getCheckbox2(): bool { return $this[self::CHECKBOX_2]; }
    public function setCheckbox2(bool $value) { $this[self::CHECKBOX_2] = $value; }

    public function getCheckbox3(): bool { return $this[self::CHECKBOX_3]; }
    public function setCheckbox3(bool $value) { $this[self::CHECKBOX_3] = $value; }

    public function getCheckbox4(): bool { return $this[self::CHECKBOX_4]; }
    public function setCheckbox4(bool $value) { $this[self::CHECKBOX_4] = $value; }

    public function getCheckbox5(): bool { return $this[self::CHECKBOX_5]; }
    public function setCheckbox5(bool $value) { $this[self::CHECKBOX_5] = $value; }

    public function getCheckbox6(): bool { return $this[self::CHECKBOX_6]; }
    public function setCheckbox6(bool $value) { $this[self::CHECKBOX_6] = $value; }

    public function getCheckbox7(): bool { return $this[self::CHECKBOX_7]; }
    public function setCheckbox7(bool $value) { $this[self::CHECKBOX_7] = $value; }

    public function getCheckbox8(): bool { return $this[self::CHECKBOX_8]; }
    public function setCheckbox8(bool $value) { $this[self::CHECKBOX_8] = $value; }

    public function getCheckbox9(): bool { return $this[self::CHECKBOX_9]; }
    public function setCheckbox9(bool $value) { $this[self::CHECKBOX_9] = $value; }
}

$checkboxes = new MyCoolCheckboxes();
$checkboxes->checkbox5 = true;
$checkboxes->checkbox7 = true;
$checkboxes->checkbox8 = true;

echo strval($checkboxes).PHP_EOL;
```

output: `gG`

---

License
-------

[](#license)

**[MIT](https://github.com/ASolomatin/php-big-bit-mask/blob/master/LICENSE)**

Copyright (C) 2020 Aleksej Solomatin

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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 ~0 days

Total

3

Last Release

2120d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0.1

1.0.1PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/54a5f58350e2aa4c12174644a9722ee4c58ce0bcc55df98023a8216a97b6da68?d=identicon)[Aleksej Solomatin](/maintainers/Aleksej%20Solomatin)

---

Top Contributors

[![ASolomatin](https://avatars.githubusercontent.com/u/10348041?v=4)](https://github.com/ASolomatin "ASolomatin (12 commits)")

---

Tags

bitmap

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/asolomatin-php-big-bit-mask/health.svg)

```
[![Health](https://phpackages.com/badges/asolomatin-php-big-bit-mask/health.svg)](https://phpackages.com/packages/asolomatin-php-big-bit-mask)
```

###  Alternatives

[matthiasnoback/php-ast-inspector

71180.6k](/packages/matthiasnoback-php-ast-inspector)[sokil/php-bitmap

Bitmap representation with bitwise operations

124.0k2](/packages/sokil-php-bitmap)

PHPackages © 2026

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