1. Go to this page and download the library: Download intraworlds/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/ */
intraworlds / enum example snippets
final class Hash extends Enum
{
const MD5 = 'md5';
const SHA1 = 'sha1';
}
$md5 = Hash::MD5();
function crack(Hash $hash) {
echo 'cracking ... ' . $hash; // notice that enum is implementing __toString() method
}
crack(Hash::SHA1()); // cracking ... sha1
crack(Hash::SHA1); // throws TypeError