{"id":15025531,"url":"https://github.com/devvoh/rights","last_synced_at":"2026-02-24T21:31:43.108Z","repository":{"id":82087976,"uuid":"177278343","full_name":"devvoh/rights","owner":"devvoh","description":"Rights is a simple bitmask-based rights system, using binary strings to represent rights.","archived":false,"fork":false,"pushed_at":"2020-05-26T19:49:30.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T01:41:23.556Z","etag":null,"topics":["acl","parable","php7","php71","php72","php73","policy","rights"],"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/devvoh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-23T11:03:42.000Z","updated_at":"2020-05-26T19:49:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"26478af6-7611-493a-b95f-2bf711cbca07","html_url":"https://github.com/devvoh/rights","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devvoh/rights","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devvoh%2Frights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devvoh%2Frights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devvoh%2Frights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devvoh%2Frights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devvoh","download_url":"https://codeload.github.com/devvoh/rights/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devvoh%2Frights/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29801021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T21:02:39.706Z","status":"ssl_error","status_checked_at":"2026-02-24T21:02:21.834Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["acl","parable","php7","php71","php72","php73","policy","rights"],"created_at":"2024-09-24T20:02:31.741Z","updated_at":"2026-02-24T21:31:43.092Z","avatar_url":"https://github.com/devvoh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rights\n\n[![License](https://poser.pugx.org/parable-php/rights/license)](https://packagist.org/packages/parable-php/rights)\n\nRights is a simple bitmask-based rights system, using binary strings to represent rights. This allows for easy storage and fast handling.\n\n## Install\n\nPhp 7.1+ and [composer](https://getcomposer.org) are required.\n\n```bash\n$ composer require parable-php/rights\n```\n\n## Usage\n\nTo create a rights instance with CRUD rights:\n\n```php\n$rights = new Rights();\n\n$rights-\u003eadd('create', 'read', 'update', 'delete');\n```\n\nThe binary string for 4 rights is `0000` (all disabled) -\u003e `1111` (all enabled).\n\n```php\n$rights-\u003ehas('0001', 'create'); // true, since last position is 1\n$rights-\u003ehas('0001', 'read'); // false, since before-last is 0\n```\n\nRights are represented in the binary string in reverse order. You can add as many rights as you want.\n\nYou can also combine two rights strings together, keeping the high values. This can be used to combine a user's individual rights and the rights set for that user's user group.\n\n```php\n$combined = $rights-\u003ecombine('1000', '0001'); // $combined = 1001\n```\n\n## API\n\n- `add(string ...$names): void` - add a right by name\n- `getAll(): int[]` - get all rights (`[string =\u003e int]`)\n- `getNames(): string[]` - get all rights' names\n- `get(string $name): ?int` - get specific right value by name\n- `can(string $provided, string $name): bool` - check if `$provided` string can take action `$name`\n- `combine(string ...$rights): string` - combine two strings, keeping the highest\n- `getRightsFromNames(string ...$names): string` - create binary string from rights passed \n- `getNamesFromRights(string $rights): string[]` - get enabled rights from binary string \n\n## Contributing\n\nAny suggestions, bug reports or general feedback is welcome. Use github issues and pull requests, or find me over at [devvoh.com](https://devvoh.com).\n\n## License\n\nRights is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevvoh%2Frights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevvoh%2Frights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevvoh%2Frights/lists"}