PHP code example of manchenkov / php-enum

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

    

manchenkov / php-enum example snippets


use Manchenkov\Enumeration\Enum;

/**
 * @method static UserType MANAGER()
 * @method static UserType ADMIN()
 */
class UserType extends Enum
{
    /**
     * @title Manager role description
     */
    private const MANAGER = 'user_manager';

    /**
     * @title Administrator role description
     */
    private const ADMIN = 'user_admin';
}

$manager = UserType::MANAGER();

$manager->getName(); // MANAGER
$manager->getValue(); // user_manager
$manager->getTitle(); // Manager role description

$manager->is(UserType::ADMIN()); // false
$manager->eq('user_manager'); // true
bash
composer 

"manchenkov/php-enum": "*"