PHP code example of darkdevlab / enum

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

    

darkdevlab / enum example snippets


use DarkDevLab\Enum\Tests\ExampleEnum;

// Usage with always object creation
$e = new ExampleEnum(ExampleEnum::ONE);
var_dump($e->getValue()); // (int) 1

// Usage with memory container (object will created only once)
$e = ExampleEnum::get(ExampleEnum::OTHER);
var_dump($e->getValue()); // (string) 'other'