Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 24 days ago
JSON representation
Helps developers manage enums and eases their use
- Host: GitHub
- URL: https://github.com/omenejoseph/enum-manager
- Owner: omenejoseph
- License: other
- Created: 2020-02-29T13:22:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-09T19:26:08.000Z (over 1 year ago)
- Last Synced: 2024-11-15T08:17:32.005Z (about 1 month ago)
- Topics: enu, enums, larave, laravel-application, laravel-framework, laravel-package
- Language: PHP
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: contributing.md
- License: license.md
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
```