phpextra/enum

Enum type for PHP

1.0.0 2014-08-16 15:44 UTC

This package is not auto-updated.

Last update: 2024-11-19 02:56:51 UTC


README

#Enum type

Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage GitTip

##Usage

###Enum (PHPExtra\Type\EnumInterface)

Create your first enum type by creating a new class:

class TheGuy extends Enum
{
    const _default = self::NICE_GUY;
    const SMART_GUY = 'Mike';
    const NICE_GUY = 'Rick';
}

Thats all.

Now you can use it:

$guy = new TheGuy();
echo $guy->getValue(); // returns Rick

$mike = new TheGuy(TheGuy::MIKE);
echo $mike->getValue(); // returns Mike

echo $guy->isEqual($mike); // returns false

If no default value will be specified, you must set it as a constructor argument. If given constructor value will be invalid, \UnexpectedValueException will be thrown.

Installation (Composer)

{
    "require": {
        "phpextra/enum":"~1.0"
    }
}

##Changelog

No releases yet

##Contributing

All code contributions must go through a pull request. Fork the project, create a feature branch, and send me a pull request. To ensure a consistent code base, you should make sure the code follows the coding standards. If you would like to help take a look at the list of issues.

##Requirements

See composer.json for a full list of dependencies.

##Authors

Jacek Kobus - <kobus.jacek@gmail.com>

License information

See the file LICENSE.txt for copying permission.