Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Milad Rahimi authored Dec 30, 2019
1 parent e39b898 commit a2c60ee
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[![Coverage Status](https://coveralls.io/repos/github/miladrahimi/php-enum/badge.svg?branch=master)](https://coveralls.io/github/miladrahimi/php-enum?branch=master)
[![License](https://poser.pugx.org/miladrahimi/php-enum/license)](https://packagist.org/packages/miladrahimi/php-enum)

# PhpEnum
# PHP-Enum

A PHP Abstract Enum Class
To make your Enums feel alive, just use the `Enum` abstract class as their parent.

## Installation

Expand All @@ -18,29 +18,29 @@ composer require miladrahimi/php-enum "1.*"

## Documentation

To make your Enum feel alive, just use the `Enum` abstract class as its parent.
Consider this enum class:

Consider `SampleEnum` in the following class.

```php
use MiladRahimi\PhpEnum\Enum;
namespace MiladRahimi\Enum\Enum;

class SampleEnum extends Enum
{
const UNO = 1;
const ONE = 1;
const TWO = 2;
const STR = "sth";
}
```

Now you are able to use declared methods in the abstract Enum class like this:
Now you are able to use this methods:

```php
SampleEnum::items(); // ['ONE' => 1, 'TWO' => 2, 'STR' => 'sth']
SampleEnum::all(); // ['UNO' => 1, 'ONE' => 1, 'TWO' => 2, 'STR' => 'sth']

SampleEnum::keys(); // ['ONE', 'TWO', 'STR'];
SampleEnum::keys(); // ['UNO', 'ONE', 'TWO', 'STR'];

SampleEnum::values(); // [1, 2, 'sth']
SampleEnum::values(); // [1, 1, 2, 'sth']

SampleEnum::hasKey('ONE'); // true

Expand All @@ -49,8 +49,14 @@ SampleEnum::hasKey('xXx'); // false
SampleEnum::hasValue(2); // true

SampleEnum::hasValue('xXx'); // false

SampleEnum::valueOf('ONE'); // 1

SampleEnum::keysOf(1); // ['UNO', 'ONE']

SampleEnum::keyOf(1); // 'UNO'
```

## License
PhpEnum is initially created by [Milad Rahimi](https://miladrahimi.com)
PHP-Enum is initially created by [Milad Rahimi](https://miladrahimi.com)
and released under the [MIT License](http://opensource.org/licenses/mit-license.php).

0 comments on commit a2c60ee

Please sign in to comment.