PHPackages                             ornament/bitflag - 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. [Database &amp; ORM](/categories/database)
4. /
5. ornament/bitflag

ActiveLibrary[Database &amp; ORM](/categories/database)

ornament/bitflag
================

Bitflag decorator for Ornament ORM

0.8.0(1y ago)0266[1 PRs](https://github.com/ornament-orm/bitflag/pulls)MITPHPPHP &gt;=8.1

Since Sep 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ornament-orm/bitflag)[ Packagist](https://packagist.org/packages/ornament/bitflag)[ RSS](/packages/ornament-bitflag/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (27)Used By (0)

ornament/bitflag
================

[](#ornamentbitflag)

Bitflag decorator for Ornament ORM

For a model Foo with a property 'status', we often want to define a number of bitflags, e.g. 'on = 1', 'valid = 2' etc. The Bitflag decorator makes this easy.

Create a backed enum defining the desired flags. Type hint the property to receive the `Bitflag` as such, and add the attribute `Ornament\Bitflag\Options`to said property. The argument to Options is the classname of your enum.

All defined cases of the enum are now magically available for getting and setting as properties on bitflag property:

```
