1. Go to this page and download the library: Download mleczek/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/ */
mleczek / enum example snippets
function printStatus(StatusEnum $status) {
echo $status->getDisplayName();
}
printStatus(StatusEnum::active()); // Active
printStatus(MyEnum::all()[0]); // PHP Fatal error: Uncaught TypeError: Argument 1 passed to printStatus() must be an instance of StatusEnum, instance of MyEnum given
use Mleczek\Enum\Enum;
final class StatusEnum extends Enum
{
public static function active(): self
{
return self::make('A', 'Active');
}
public static function inactive(): self
{
return self::make('I', 'Inactive');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.