A simple PHP Enum implementation

v1.0.0 2017-04-24 20:58 UTC

This package is auto-updated.

Last update: 2024-11-13 10:55:28 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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.