PHP code example of putraits / enums
1. Go to this page and download the library: Download putraits/enums 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/ */
putraits / enums example snippets
use putraits\enums\traits\NameFrom\NameFromInterface;
use putraits\enums\traits\NameFrom\NameFromTrait;
enum TestSuitBackedEnum: string implements NameFromInterface
{
use NameFromTrait;
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
var_dump(TestSuitBackedEnum::tryNameFrom('Hearts')); // enum(TestSuitBackedEnum::Hearts)