bbrothers / enum
A simple PHP Enum implementation
v1.0.0
2017-04-24 20:58 UTC
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: ~6.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-10-13 10:36:52 UTC
README
A very simple PHP Enum implementation.
Install
Via Composer
$ composer require bbrothers/enum
Usage
class Weekdays extends Enum { const MONDAY = 'monday'; const TUESDAY = 'tuesday'; const WEDNESDAY = 'wednesday'; const THURSDAY = 'thursday'; const FRIDAY = 'friday'; } // ... $day = Weekdays::TUESDAY(); $day->equals(Weekdays::MONDAY()); // false $day->isSelected(Weekdays::TUESDAY); // true (string) $day; // tuesday Weekdays::values(); // monday, tuesday, wednesday, thursday, friday Weekdays::keys(); // MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.