PHP code example of labrodev / php-enum-mapper

1. Go to this page and download the library: Download labrodev/php-enum-mapper 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/ */

    

labrodev / php-enum-mapper example snippets

 



namespace YourNamespace;

use Labrodev\PhpEnumMapper\EnumMapper;

class YourClass
{
    public function exampleMethod()
    {
        // Assuming you have an Enum OrderStatus
        $cases = OrderStatus::cases();

        // Convert Enum cases to an array of values and translated names
        $mappedValues = EnumMapper::keyValues($cases);

        // Extract only the Enum values
        $enumValues = EnumMapper::keys($cases);
    }
}

bash
composer 
bash
composer analyse