{"id":15583699,"url":"https://github.com/sokil/php-bitmap","last_synced_at":"2025-04-24T03:45:31.547Z","repository":{"id":22121638,"uuid":"25452303","full_name":"sokil/php-bitmap","owner":"sokil","description":"Bitmap representation with bitwise operations","archived":false,"fork":false,"pushed_at":"2021-03-17T10:34:18.000Z","size":36,"stargazers_count":12,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T03:45:27.862Z","etag":null,"topics":["binary","bitarray","bitmap","bitmask","mask","php"],"latest_commit_sha":null,"homepage":"","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/sokil.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":"2014-10-20T05:39:34.000Z","updated_at":"2024-11-01T10:59:35.000Z","dependencies_parsed_at":"2022-08-19T15:00:54.713Z","dependency_job_id":null,"html_url":"https://github.com/sokil/php-bitmap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-bitmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-bitmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-bitmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sokil%2Fphp-bitmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sokil","download_url":"https://codeload.github.com/sokil/php-bitmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250559994,"owners_count":21450168,"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":["binary","bitarray","bitmap","bitmask","mask","php"],"created_at":"2024-10-02T20:20:31.286Z","updated_at":"2025-04-24T03:45:31.527Z","avatar_url":"https://github.com/sokil.png","language":"PHP","readme":"php-bitmap\n==========\n\n[![Total Downloads](http://img.shields.io/packagist/dt/sokil/php-bitmap.svg?1)](https://packagist.org/packages/sokil/php-bitmap/stats)\n[![Daily Downloads](https://poser.pugx.org/sokil/php-bitmap/d/daily)](https://packagist.org/packages/sokil/php-bitmap/stats)\n[![Build](https://github.com/sokil/php-bitmap/workflows/Test/badge.svg?branch=master)](https://github.com/sokil/php-bitmap/actions?query=workflow%3ATest)\n\nBitmap, also called bit array is a data structure that \ncompactly store set of values as bits of integer.\nMore data can be read at http://en.wikipedia.org/wiki/Bit_array.\n\nIt is useful when required compact way to represent combination \nof values and simple manipulations with them. One byte can \nrepresent eight independent values.\n\n### Installation\n\n```\ncomposer require sokil/php-bitmap\n```\n\n### Useage\n\nLets see example. Errors in PHP represents as constants:\n\n```\nE_ERROR = 1 (0);\nE_WARNING = 2 (1);\nE_PARSE = 4 (2);\nE_NOTICE = 8 (3);\nE_CORE_ERROR = 16 (4);\nE_CORE_WARNING = 32 (5);\nE_COMPILE_ERROR = 64 (6);\nE_COMPILE_WARNING = 128 (7);\nE_USER_ERROR = 256 (8);\nE_USER_WARNING = 512 (9);\nE_USER_NOTICE = 1024 (10);\nE_STRICT = 2048 (11);\nE_RECOVERABLE_ERROR = 4096 (12);\nE_DEPRECATED = 8192 (13);\nE_USER_DEPRECATED = 16384 (14);\nE_ALL = 32767 (15);\n```\n\nEvery error level represent logical \"1\", and combination of all this \nvalues may be represent only by two bytes. E_ERROR represent first bit of byte,\nE_WARNING - second, etc.\n\nCombination of E_WARNING and E_NOTICE in binary system is \"1010\" or 10 in decimal system.\n\nClass that represents bitmap of PHP errors:\n\n```php\nclass PhpError extends \\Sokil\\Bitmap\n{\n    /**\n     * Show errors\n     * Set first bit, which represents E_ERROR, to \"1\"\n     */\n    public function showErrors()\n    {\n        $this-\u003esetBit(0);\n        return $this;\n    }\n\n    /**\n     * Hide errors\n     * Set first bit, which represents E_ERROR, to \"0\"\n     */\n    public function hideErrors()\n    {\n        $this-\u003eunsetBit(0);\n        return $this;\n    }\n\n    /**\n     * Check if errors shown\n     * Check if first bit set to 1\n     */\n    public function isErrorsShown()\n    {\n        return $this-\u003eisBitSet(0);\n    }\n\n    /**\n     * Show warnings\n     * Set second bit, which represents E_WARNING, to \"1\"\n     */\n    public function showWarnings()\n    {\n        $this-\u003esetBit(1);\n        return $this;\n    }\n\n    /**\n     * Hide warnings\n     * Set second bit, which represents E_WARNING, to \"0\"\n     */\n    public function hideWarnings()\n    {\n        $this-\u003eunsetBit(1);\n        return $this;\n    }\n\n    /**\n     * Check if warnings shown\n     * Check if second bit set to 1\n     */\n    public function isWarningsShown()\n    {\n        return $this-\u003eisBitSet(1);\n    }\n}\n```\n\nNow we can easely manipulate with errors:\n```php\n\n// load current error levels\n$error = new PhpError(error_reporting());\n\n// enable errors and warnings\n$error-\u003eshowErrors()-\u003eshowWarnings();\n\n// set error reporting\nerror_reporting($error-\u003etoInt());\n\n// check if warnings shown\nvar_dump($error-\u003eisWarningsShown());\n\n// value may be set by mask\n// E_USER_ERROR | E_USER_WARNING is 256 + 512;\n$error-\u003esetBitsByMask(E_USER_ERROR | E_USER_WARNING);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsokil%2Fphp-bitmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsokil%2Fphp-bitmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsokil%2Fphp-bitmap/lists"}