PHP code example of anteris-dev / enum-descriptions
1. Go to this page and download the library: Download anteris-dev/enum-descriptions 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/ */
anteris-dev / enum-descriptions example snippets
use AnterisDev\EnumDescriptions\Description;
enum Animal
{
#[Description('A cute dog.')]
case Dog;
#[Description('A fuzzy cat.')]
case Cat;
}
// Accepts an enum class name and returns an array. Enum values are represented in the array keys
// and enum descriptions are represented as those key values.
enum_descriptions(Animal::class);
// Returns the string description for the specific enum passed.
enum_description(Animal::Dog);
use AnterisDev\EnumDescriptions\HasDescriptions;
enum Animal
{
use HasDescriptions;
}
// Returns an array. Enum values are represented in the array keys and enum
// descriptions are represented as those key values.
Animal::descriptions();
// Returns the description for the specific value specified.
Animal::Dog->description();