1. Go to this page and download the library: Download vicgutt/php-enhanced-enum library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vicgutt / php-enhanced-enum example snippets
use VicGutt\PhpEnhancedEnum\Concerns\Enumerable;
use VicGutt\PhpEnhancedEnum\Contracts\EnumerableContract;
enum MyEnum: string implements EnumerableContract
{
use Enumerable;
case CASE1 = 'case1';
case CASE2 = 'case2';
}
use VicGutt\PhpEnhancedEnum\Concerns\Enumerable;
use VicGutt\PhpEnhancedEnum\Contracts\EnumerableContract;
/**
* A "unit enum"
*/
enum MovementsEnum implements EnumerableContract
{
use Enumerable;
case ME_TOO;
case BLACK_LIVES_MATTER;
case LGBTQ_PLUS;
case AND_MANY_MANY_MORE;
}
/**
* An integer typed "backed enum"
*/
enum PromiseEnum: int implements EnumerableContract
{
use Enumerable;
case PENDING = 1;
case RESOLVED = 2;
case REJECTED = 3;
}
/**
* A string typed "backed enum"
*/
enum StatusEnum: string implements EnumerableContract
{
use Enumerable;
case PENDING = 'pending';
case SUCCEEDED = 'succeeded';
case FAILED = 'failed';
}