{"id":15296368,"url":"https://github.com/phoenixrvd/bitmask","last_synced_at":"2025-03-25T05:43:46.047Z","repository":{"id":57039110,"uuid":"138226713","full_name":"phoenixrvd/bitmask","owner":"phoenixrvd","description":"Simple bitmask utility","archived":false,"fork":false,"pushed_at":"2019-05-07T08:00:44.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T05:26:38.247Z","etag":null,"topics":["bitmask","clean-code","mit","open-source","php-library","php7","php71","php72"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phoenixrvd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-21T22:10:18.000Z","updated_at":"2019-05-07T08:00:45.000Z","dependencies_parsed_at":"2022-08-24T00:50:45.998Z","dependency_job_id":null,"html_url":"https://github.com/phoenixrvd/bitmask","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixrvd%2Fbitmask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixrvd%2Fbitmask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixrvd%2Fbitmask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoenixrvd%2Fbitmask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phoenixrvd","download_url":"https://codeload.github.com/phoenixrvd/bitmask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407755,"owners_count":20610232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitmask","clean-code","mit","open-source","php-library","php7","php71","php72"],"created_at":"2024-09-30T18:10:14.002Z","updated_at":"2025-03-25T05:43:46.028Z","avatar_url":"https://github.com/phoenixrvd.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitmask\n\n[![Minimum PHP Version](https://img.shields.io/badge/php-\u003e=7.0-8892BF.svg)](https://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/phoenixrvd/bitmask/v/stable.svg)](https://packagist.org/packages/phoenixrvd/bitmask)\n[![composer.lock](https://poser.pugx.org/phoenixrvd/bitmask/composerlock)](https://packagist.org/packages/phoenixrvd/bitmask)\n[![License](https://poser.pugx.org/phoenixrvd/bitmask/license)](https://packagist.org/packages/phoenixrvd/bitmask)\n\n[![Build Status](https://travis-ci.org/phoenixrvd/bitmask.png?branch=master)](https://travis-ci.org/phoenixrvd/bitmask)\n[![Code Climate](https://codeclimate.com/github/phoenixrvd/bitmask.png)](https://codeclimate.com/github/phoenixrvd/bitmask)\n[![StyleCI](https://styleci.io/repos/138226713/shield?branch=master)](https://styleci.io/repos/138226713)\n[![Test Coverage](https://codeclimate.com/github/phoenixrvd/bitmask/badges/coverage.svg)](https://codeclimate.com/github/phoenixrvd/bitmask/coverage)\n[![BCH compliance](https://bettercodehub.com/edge/badge/phoenixrvd/bitmask)](https://bettercodehub.com/results/phoenixrvd/bitmask)\n[![Latest Unstable Version](https://poser.pugx.org/phoenixrvd/bitmask/v/unstable.svg)](https://packagist.org/packages/phoenixrvd/bitmask)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Installation](#installation)\n- [Example](#example)\n- [Testing](#testing)\n- [Copyright and license](#copyright-and-license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\nIn PHP a number is (mostly) 4 Bytes long. This means that one number actually uses 32 bits of the internal storage.\n\nIn this case 32 boolean values can be stored as single integer.  The problem ist a 'magic numbers'.\n\n## Installation\n\nInstall the latest version with\n\n```bash\ncomposer require phoenixrvd/bitmask\n```\n## Example\n\nWithout this API [before.php](examples/before.php)\n\n```php\n\u003c?php\n\nclass StateMap {\n    const OPTION_1 = 1;\n    const OPTION_2 = 2;\n    const OPTION_4 = 4;\n    // What is next ????\n}\n\n// Check for Active Feature\n$activeFeatures = 6;\n\nif(($activeFeatures \u0026 StateMap::OPTION_1) === StateMap::OPTION_1){\n    // Do this\n}\n\nif(($activeFeatures \u0026 StateMap::OPTION_2) !== StateMap::OPTION_2) {\n    // Do this\n}\n\n// Activation and deactivation from options ist not 'Human Readable'.\n```\n\nWith this API  [after.php](examples/after.php)\n\n```php\n\u003c?php\n\nclass StateMap {\n    const OPTION_1 = 0;\n    const OPTION_2 = 1;\n    const OPTION_4 = 2;\n    const OPTION_5 = 3;\n    const OPTION_6 = 4;\n}\n\n// Check for Active Feature\n$activeFeatures = (new \\PhoenixRVD\\Bitmask\\BitmaskFactory())-\u003efromInt(6);\n\nif($activeFeatures-\u003eisOn(StateMap::OPTION_1)){\n    // Do this\n}\n\nif($activeFeatures-\u003eisOff(StateMap::OPTION_2)) {\n    // Do that\n}\n\n// Activate options\n$activeFeatures-\u003eon(StateMap::OPTION_5, StateMap::OPTION_6);\n\n// Deactivate options\n$activeFeatures-\u003eoff(StateMap::OPTION_4, StateMap::OPTION_1);\n```\n\n## Testing\n\n```bash\ncomposer bitmask:test\n```\n\n## Copyright and license\n\nCode released under the [MIT License](LICENSE). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoenixrvd%2Fbitmask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphoenixrvd%2Fbitmask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoenixrvd%2Fbitmask/lists"}