PHPackages                             yii2mod/yii2-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. yii2mod/yii2-enum

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

yii2mod/yii2-enum
=================

Yii2 Enumerable helpers

1.7.1(9y ago)63941.1k↓17.6%14[1 issues](https://github.com/yii2mod/yii2-enum/issues)20MITPHPPHP &gt;=5.6CI failing

Since Jun 17Pushed 6y ago3 watchersCompare

[ Source](https://github.com/yii2mod/yii2-enum)[ Packagist](https://packagist.org/packages/yii2mod/yii2-enum)[ RSS](/packages/yii2mod-yii2-enum/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (20)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Enum Extension for Yii2
=======================

[](#enum-extension-for-yii2)

Enum implementation for Yii Framework 2.0

[![Latest Stable Version](https://camo.githubusercontent.com/3f0cafa8ae06b0fdaa3fd15c5b0443c2ebb4c15c45a5a3f457fe393a2e430155/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d656e756d2f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-enum) [![Total Downloads](https://camo.githubusercontent.com/17ce6aeb300bd06948a6a654160ea53f650b6cd3c21bfe19d2da8fd72814ebfe/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d656e756d2f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-enum) [![License](https://camo.githubusercontent.com/e4c9a402a0d7b417e2fbe632687b7dbaecc22e1ba8c00e90c3e0aa5c62301a7a/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d656e756d2f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-enum)[![Build Status](https://camo.githubusercontent.com/7615c86af9fcdf42933f43bbf5453a1433445cbbd5c9d8db87ad0ee2e8762bca/68747470733a2f2f7472617669732d63692e6f72672f796969326d6f642f796969322d656e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2mod/yii2-enum)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ac23b838bc1ce13113dee3e15766903dcc4b92e43be15024472b6ca9dc910cd1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796969326d6f642f796969322d656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yii2mod/yii2-enum/?branch=master)

Support us
----------

[](#support-us)

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/yii2mod). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist yii2mod/yii2-enum "*"

```

or add

```
"yii2mod/yii2-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)

```
