PHP code example of kuria / enum

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

    

kuria / enum example snippets



   

   use Kuria\Enum\Enum


   

   use Kuria\Enum\Enum


   

   var_dump(
       DayOfTheWeek::hasKey('MONDAY'),
       DayOfTheWeek::hasValue(0)
   )


   

   DayOfTheWeek::ensureKey('MONDAY');
   DayOfTheWeek::ensureValue(0)


   

   var_dump(
       DayOfTheWeek::getValue('FRIDAY'),
       DayOfTheWeek::getKey(4)
   )


   

   echo 'DayOfTheWeek::getKeys(): '; print_r(DayOfTheWeek::getKeys());
   echo 'DayOfTheWeek::getValues(): '; print_r(DayOfTheWeek::getValues());
   echo 'DayOfTheWeek::getMap(): '; print_r(DayOfTheWeek::getMap());
   echo 'DayOfTheWeek::getKeyMap(): '; print_r(DayOfTheWeek::getKeyMap());
   echo 'DayOfTheWeek::getValueMap(): '; print_r(DayOfTheWeek::getValueMap())


   

   var_dump(DayOfTheWeek::getPair(DayOfTheWeek::MONDAY));
   var_dump(DayOfTheWeek::getPairByKey('FRIDAY'))


   

   var_dump(DayOfTheWeek::count())


   

   use Kuria\Enum\EnumObject


   

   $color = Color::fromValue(Color::RED)


   

   $color = Color::fromKey('GREEN')


   

   $color = Color::BLUE()


   

   var_dump(Color::all())


   

   $color = Color::RED()


   

   $color = Color::GREEN()


  

   $color = Color::RED()


   

   $color = Color::BLUE()


   

   use Kuria\Enum\EnumObject