PHP code example of fixmind / enum

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

    

fixmind / enum example snippets


class Vertical extends Enum
{
	const TOP = 'TOP';
	const MIDDLE = 'MIDDLE';
	const BOTTOM = 'BOTTOM';
}

// OR

class Horizontal extends Enum
{
	const VALUE = ['LEFT', 'CENTER', 'RIGHT'];
}

class MyClass
{
	public function __construct(Vertical $vertical)
	{
	}
}

new MyClass(Vertical::TOP());

if (Vertical::TOP() == 'TOP')
{
	if (Vertical::TOP()->is(Vertical::TOP))
	{
	}
}

foreach(Vertical::getOptionList() as $option)
{
	echo $option;
}

if (Vertical::isValid('TOP'))
{
	echo 'TOP is a valid value of Vertical Enum';
}
if (Vertical::isValid('LEFT') == false)
{
	echo 'LEFT is not a valid value of Vertical Enum';
}