PHP code example of simondeeley / enum

1. Go to this page and download the library: Download simondeeley/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/ */

    

simondeeley / enum example snippets


use simondeeley\enum;

class MyAwesomeEnum extends Enum
{
    const FOO = 'FOO';
    const BAR = 'BAR';
}

use Acme\MyAwesomeEnum;

$good = new MyAwesomeEnum('FOO');
$bad = new MyAwesomeEnum('BAZ'); // throws an exception

use simondeeley\Enums\Boolean;
use simondeeley\Enums\Weekday;

$true = new Boolean('TRUE');
$true->getValue(); // returns (bool) true

$tuesday = new Weekday('TUESDAY');
$tuesday->getValue(); // returns (string) "Tuesday"

$true = Boolean::true();

$saturday = Weekday::Saturday();