PHP code example of bronos / php-enum
1. Go to this page and download the library: Download bronos/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/ */
bronos / php-enum example snippets
use BronOS\PhpEnum\ConstEnum;
class MyEnum extends ConstEnum
{
private const ONE = 1;
private const TWO = 2;
private const THREE = 3;
}
$enumOne = MyEnum::ONE(); // $enumOne->getValue() == 1
$enumTwo = MyEnum::TWO(); // $enumTwo->getValue() == 2
$enumTree = new MyEnum(3); // $enumThree->getValue() == 3
$enumOne->getOptionName() == 'ONE';
$enumOne->isEqual(1) == true;
MyEnum::isValid(5) == false;
new MyEnum(4); // EnumException
composer