PHP code example of adam-lutka / php-enum

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

    

adam-lutka / php-enum example snippets



 * @method static TypeEnum TYPE_1()
 * @method static $this TYPE_2()
 */
final class TypeEnum extends \AL\PhpEnum\Enum {}


var_dump((string)TypeEnum::TYPE_2());                        // string(6) "TYPE_2"
var_dump(TypeEnum::TYPE_2()->getValue());                    // string(6) "TYPE_2"
var_dump(TypeEnum::TYPE_1()->getOrder());                    // int(0)
var_dump(TypeEnum::TYPE_2()->getOrder());                    // int(1)
var_dump(TypeEnum::TYPE_2() === TypeEnum::TYPE_2());         // bool(true)
var_dump(TypeEnum::TYPE_2() == TypeEnum::TYPE_2());          // bool(true)
var_dump(TypeEnum::TYPE_1() === TypeEnum::TYPE_2());         // bool(false)
var_dump(TypeEnum::TYPE_1() == TypeEnum::TYPE_2());          // bool(false)
var_dump(TypeEnum::parse('TYPE_2') === TypeEnum::TYPE_2());  // bool(true)
var_dump(TypeEnum::tryParse('NOT_EXIST'));                   // NULL
var_dump(TypeEnum::inOrder(0) === TypeEnum::TYPE_1());       // bool(true)
var_dump(TypeEnum::tryInOrder(1000));                        // NULL

composer