Skip to content

Commit a5cdf1a

Browse files
author
Kevin Buchholz
committed
Merge branch 'master' into develop
2 parents 992ccb1 + a8489c9 commit a5cdf1a

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
[![Packagist downloads](https://img.shields.io/packagist/dt/sourceboat/laravel-enumeration.svg?style=flat-square)](https://packagist.org/packages/sourceboat/laravel-enumeration)
77
[![MIT Software License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.md)
88

9-
Strongly typed enum implementation for Laravel. Based on [eloquent/enumeration](https://github.com/eloquent/enumeration) and inspired by [bensampo/laravel-enum](https://github.com/bensampo/laravel-enum)
9+
Enum implementation for Laravel. Based on [eloquent/enumeration](https://github.com/eloquent/enumeration) and inspired by [bensampo/laravel-enum](https://github.com/bensampo/laravel-enum)
1010

1111
## Features
1212

13-
* Strongly typed
1413
* Key/value-definition via class constants
1514
* Full featured suite of methods
1615
* Enum artisan generator
1716
* Validation rules for passing enum values as input parameters
1817
* Localization support
19-
* Extendible
18+
* Extensible
2019

2120
## Table of Contents
2221

@@ -41,10 +40,12 @@ Strongly typed enum implementation for Laravel. Based on [eloquent/enumeration](
4140
Via Composer
4241

4342
``` bash
43+
4444
$ composer require sourceboat/laravel-enumeration
4545
```
4646

4747
If you're using Laravel < 5.5 you'll need to add the service provider to `config/app.php`
48+
4849
``` php
4950
'Sourceboat\Enumeration\EnumerationServiceProvider'
5051
```
@@ -58,6 +59,7 @@ php artisan make:enum UserType
5859
## Usage
5960

6061
Given the following enum:
62+
6163
``` php
6264
<?php
6365

@@ -81,6 +83,7 @@ final class UserType extends Enumeration
8183
```
8284

8385
Values can now be accessed like so:
86+
8487
``` php
8588
UserType::Moderator() // Returns an instance of UserType with UserType::Moderator()->value === 1
8689
```
@@ -190,6 +193,7 @@ UserType::toLocalizedSelectArray(); // Returns [0 => 'Administrator', 1 => 'Mode
190193
## Validation
191194

192195
### Array Validation
196+
193197
You may validate that a value passed to a controller is a valid value for a given enum by using the `EnumerationValue` rule, for easier handling there are helper methods for creating the rule: `Enumeration::makeRule()`, `Enumeration::makeRuleWithWhitelist($whitelist)` and `Enumeration::makeRuleWithBlacklist($blacklist)`.
194198

195199
``` php
@@ -330,8 +334,3 @@ Much of the functionality in this Package is inspired by [bensampo/laravel-enum]
330334
- [laravel/framework](https://github.com/laravel/framework) is licensed under MIT
331335

332336
This package is also licensed under the MIT license.
333-
334-
## TODOs
335-
336-
* [x] Tests for all enumeration-functions and the rule.
337-
* [x] Model-Trait to enable casting of enumerations and "on the fly"-validation for enumeration values on models.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"consistence/coding-standard": "3.7",
3333
"orchestra/testbench": "~3.0 || 4.*",
3434
"phpmd/phpmd": "^2.6",
35-
"phpunit/phpunit": "7.4.* || 8.3.*",
35+
"phpunit/phpunit": "7.4.* || 8.3.* || 8.4.*",
3636
"slevomat/coding-standard": "4.8.7",
3737
"squizlabs/php_codesniffer": "^3.4"
3838
},

0 commit comments

Comments
 (0)