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

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

indifferend/yii2-enum
=====================

Yii2 Enumerable helpers

2.1(4y ago)062MITPHPPHP &gt;=5.6

Since Jun 2Pushed 4y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (2)

 [ ![](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/fdaaa693783e3aac5138d28e99f22b64494c811942bdd79128ad120abbe07ce7/68747470733a2f2f706f7365722e707567782e6f72672f696e646966666572656e642f796969322d656e756d2f762f737461626c65)](https://packagist.org/packages/indifferend/yii2-enum) [![Total Downloads](https://camo.githubusercontent.com/d4e72ec188c1a205f9d8de79c93c4b71e859ab7a7b0ade8380607d49a410b088/68747470733a2f2f706f7365722e707567782e6f72672f696e646966666572656e642f796969322d656e756d2f646f776e6c6f616473)](https://packagist.org/packages/indifferend/yii2-enum) [![License](https://camo.githubusercontent.com/5547420c676258fb71bf3c55f26ba6f30d5cc9d36aa20a38d156aa5a730962b9/68747470733a2f2f706f7365722e707567782e6f72672f696e646966666572656e642f796969322d656e756d2f6c6963656e7365)](https://packagist.org/packages/indifferend/yii2-enum)[![Build Status](https://camo.githubusercontent.com/be7049abf79596e5e2f4ebe370c5e560bec1c8bb76481798dc6e1d31cae8108d/68747470733a2f2f7472617669732d63692e6f72672f696e646966666572656e642f796969322d656e756d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/indifferend/yii2-enum)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/aa211a1c6fd7d67ccf492e36e7f1427d60bb94434af60cdc0d984402984902d9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e646966666572656e642f796969322d656e756d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/indifferend/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/indifferend). 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 indifferend/yii2-enum "*"

```

or add

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

```
