PHPackages                             adrenalinkin/enum-mapper - 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. [Database &amp; ORM](/categories/database)
4. /
5. adrenalinkin/enum-mapper

ActiveLibrary[Database &amp; ORM](/categories/database)

adrenalinkin/enum-mapper
========================

Component provides easy way to emulate ENUM behaviour on the PHP layer instead database and convert DB value into human representation and vise versa

v1.0.3(8y ago)1381MITPHPPHP ~5.4||~7.0

Since Jul 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/adrenalinkin/enum-mapper)[ Packagist](https://packagist.org/packages/adrenalinkin/enum-mapper)[ RSS](/packages/adrenalinkin-enum-mapper/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (5)Used By (1)

Enum Mapper [![На Русском](https://camo.githubusercontent.com/feb4c9ee227a5ee3a5d4e83a8a5b888b2e4b666d6cc2fb985c3bf404f8f271ac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2544302539462544302542352544312538302544302542352544302542392544312538322544302542385f2544302542442544302542302d2544302541302544312538332544312538312544312538312544302542412544302542382544302542392d677265656e2e7376673f7374796c653d666c61742d737175617265)](./README.RU.md)
=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#enum-mapper-)

Introduction
------------

[](#introduction)

Component provides easy way to emulate `ENUM` behaviour on the `PHP` layer instead database by constant usage. Convert database value into human representation and vise versa.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this component:

```
    composer require adrenalinkin/enum-mapper
```

*This command requires you to have [Composer](https://getcomposer.org) install globally.*

Usage examples
--------------

[](#usage-examples)

### Mapper creation

[](#mapper-creation)

For start create mapper-class and extend him from [AbstractEnumMapper](./Mapper/AbstractEnumMapper.php). For second and last step - determine list of the constants with specific prefixes:

- **DB\_** - contains database values.
- **HUMAN\_** - contains humanized values.

Let's say we need to store user's gender. In that case we need to create mapper-class:

```
