1. Go to this page and download the library: Download laudis/typed-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/ */
laudis / typed-enum example snippets
final class Foo extends TypedEnum {
private const BAR = 'bar';
private const BAZ = 2;
private const FOO = 2.1;
}
Foo::BAR(); // Returns an instance of Foo with value 'bar'
function isBar(Foo $enum): bool {
return Foo::BAR() === $enum;
}