1. Go to this page and download the library: Download vaened/php-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/ */
namespace App\Enums;
use App\Color;
use Vaened\Enum\Attributor;
use Vaened\Enum\Enum;
class Status extends Enum
{
// Enums
public const WARNING = 'Advertencia';
public const SUCCESS = 'Exito';
}
use App\Enums\Status;
// returns an instance of Status, with the value of the constant WARNING
Status::WARNING();
class Status extends Enum
{
public const WARNING = 'Advertencia';
public static function WARNING(): self
{
return self::create(self::WARNING);
}
}
/**
* Class Status
*
* @method static Status WARNING()
*/
class Status extends Enum
{
public const WARNING = 'Advertencia';
}
class Status extends Enum
{
public const SUCCESS = 'Éxito';
public function getColor(): Color
{
return $this->attribute('color');
}
protected static function attributes(): array
{
return [
Attributor::to('SUCCESS', [
'color' => new Color('blue'),
]),
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.