PHP code example of robusto / enum

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

    

robusto / enum example snippets


class DayWeekEnum extends Enum
{
	const SUNDAY    = 1,
	      MONDAY    = 2,
	      TUESDAY   = 3,
	      WEDNESDAY = 4,
	      THURSDAY  = 5,
	      FRIDAY    = 6,
	      SATURDAY  = 7
    ;
}

class LanguageEnum extends Enum
{
    const JAVA   = 1,
	      PHP    = 2,
	      PYTHON = 3,
	      RUBY   = 4,
	      JS     = 5
    ;

    protected static $descriptions = [
    	'Java',
    	'PHP',
    	'Python',
    	'Ruby',
    	'Javascript'
    ];
}

public function setLanguage(LanguageEnum $language) 
{
    $this->language = $language;
}

$language = LanguageEnum::JAVA();

$foo->setLanguage($language);