1. Go to this page and download the library: Download tailflow/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/ */
tailflow / enum example snippets
use Tailflow\Enum\Enum;
class Status extends Enum
{
public const Inactive = 0;
public const Active = 1;
public const OnHold = 3;
}
$class->setStatus(Status::Inactive);
// $label will be equal to "OnHold" - the name of the constant
$label = Status::getLabel(Status::OnHold);
use Tailflow\Enum\Enum;
class Status extends Enum
{
public const Inactive = 0;
public const Active = 1;
public const OnHold = 3;
public static function labels(): array
{
return [
self::OnHold => 'waiting'
];
}
}
// $label will be equal to "waiting" - the custom label defined in "labels" method
$label = Status::getLabel(Status::OnHold);
// $labels will contain the array - ['Inactive', 'Active', 'waiting']
$labels = Status::getLabels();
// $labels will contain the array - [0, 1, 3]
$labels = Status::getValues();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.