Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/omenejoseph/enum-manager

Helps developers manage enums and eases their use
https://github.com/omenejoseph/enum-manager

enu enums larave laravel-application laravel-framework laravel-package

Last synced: 2 days ago
JSON representation

Helps developers manage enums and eases their use

Awesome Lists containing this project

README

        

# EnumManager

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Build Status][ico-travis]][link-travis]
[![StyleCI][ico-styleci]][link-styleci]

This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.

## Installation

Via Composer

``` bash
$ composer require omenejoseph/enummanager
```

## Usage
To create an Enum class
``` bash
$ php artisan make:enum gender_enum
```
This command would create a class GenderEnum in an Enum directory on app folder.
This class just contains constants that are your actual enums.
```
["string", "required"],
"gender" => ["required", "in:male,female"]
];
//can now be:
$validation_array = [
"name" => ["string", "required"],
"gender" => ["required", "in:".EnumManager::enumValues(GenderEnum::class)]
];
```
Do not forget to import class namespaces and use them

```
OmeneJoseph\EnumManager\Facades\EnumManager
App\Enums\GenderEnum
```
This can really be helpful if you have a lot of enums


2. EnumManager::enumValuesArray()
- This accepts the class part of an enum class that extends OmeneJoseph\EnumManager\EnumManager as argument
- This returns an array of the various constants in that class.
Sample use case
Checking if a certain string exists in your enum list
```