PHPackages                             corp-soft/php-enum - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. corp-soft/php-enum

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

corp-soft/php-enum
==================

PHP Enum implementation

1.0.0(8y ago)5520MITPHPPHP &gt;=7.1

Since Nov 27Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Corp-Soft/php-enum)[ Packagist](https://packagist.org/packages/corp-soft/php-enum)[ RSS](/packages/corp-soft-php-enum/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

 [![](https://avatars1.githubusercontent.com/u/33844443)](https://avatars1.githubusercontent.com/u/33844443)

PHP Enum implementation
=======================

[](#php-enum-implementation)

[![Latest Stable Version](https://camo.githubusercontent.com/b555a18239c71f7b5a8ab4ff137ee375d64b63580662c47f8819b557efad9b5b/68747470733a2f2f706f7365722e707567782e6f72672f636f72702d736f66742f7068702d656e756d2f762f737461626c65)](https://packagist.org/packages/corp-soft/php-enum)[![Total Downloads](https://camo.githubusercontent.com/9f518f8aca73042603ed122f9eef25aa703f23afc170ba66fc994325c8bb8090/68747470733a2f2f706f7365722e707567782e6f72672f636f72702d736f66742f7068702d656e756d2f646f776e6c6f616473)](https://packagist.org/packages/corp-soft/php-enum)[![License](https://camo.githubusercontent.com/322cb59edea2528a20af1317f950c9de8ed5f0aae5cf2acd87b2772ed42d0f3f/68747470733a2f2f706f7365722e707567782e6f72672f636f72702d736f66742f7068702d656e756d2f6c6963656e7365)](https://packagist.org/packages/corp-soft/php-enum)[![Build Status](https://camo.githubusercontent.com/3b89c098d3f2485cc5c668154d451cfd08df1f9ef8043b77c9db8ca17b5ae6ac/68747470733a2f2f7472617669732d63692e6f72672f436f72702d536f66742f7068702d656e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Corp-Soft/php-enum)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1f0eceb52ec8ba386e33c9b7cd90f16bea8eae583e14766dbc58670bfcb14464/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f436f72702d536f66742f7068702d656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Corp-Soft/php-enum/?branch=master)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist corp-soft/php-enum "*"

```

or add

```
"corp-soft/php-enum": "*"

```

to the require section of your `composer.json` file.

Available Methods:
------------------

[](#available-methods)

- `createByName()` - Creates a new type instance using the name of a value.
- `getValueByName()` - Returns the constant key by value(label)
- `createByValue()` - Creates a new type instance using the value.
- `listData()` - Returns the associative array with constants values and labels
- `getLabel()`- Returns the constant label by key
- `getConstantsByName()` - Returns the list of constants (by name) for this type.
- `getConstantsByValue()` - Returns the list of constants (by value) for this type.
- `isValidName()` - Checks if a name is valid for this type.
- `isValidValue()` - Checks if a value is valid for this type.

Declaration
-----------

[](#declaration)

```
