PHP Classes


Recommend this page to a friend!
  Classes of Matous Nemec   PHP Enum Value   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Enum Value
Create enumerated value objects from constants
Author: By
Last change:
Date: 1 year ago
Size: 811 bytes


Class file image Download


The main advantages of using enums for representing set of values are:

  • you can be sure, that the value is unchanged (not only validated once)
  • you can use type hints to check that only the defined set of values is acceptable
  • you can define behavior on top of the represented values
  • you can define properties for enum values


Library mesour/enum requires PHP 7.1 or higher.


The best way to install mesour/enum is using Composer.

  • Run command `composer require mesour/enum`.


Learn more in the documentation.

How to run tests

  • Run command `vendor/bin/tester -c tests/php.ini tests`.