PHP code example of sunkan / enum
1. Go to this page and download the library: Download sunkan/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/ */
sunkan / enum example snippets
use Sunkan\Enum\Enum;
/**
* Action enum
*/
class Action extends Enum
{
private const VIEW = 'view';
private const EDIT = 'edit';
}
$action = Action::fromValue('view');
// or
$action = Action::VIEW();
function setAction(Action $action) {
// ...
}