PHP code example of ronildo-sousa / enumer

1. Go to this page and download the library: Download ronildo-sousa/enumer 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/ */

    

ronildo-sousa / enumer example snippets


$json = '{"Hearts": "H", "Diamonds": "D", "Clubs": "C", "Spades": "S"}';

$enumer = new RonildoSousa\Enumer();
$enumer->convertJson(json: $json, file_path: '/Enums/Test.php');

enum Test: string
{
    
   case Hearts = "H";

   case Diamonds = "D";

   case Clubs = "C";

   case Spades = "S";

}

$json = '{"Guest": 1, "Editor": 2, "Admin": 3, "Owner": 4}';

$enumer = new RonildoSousa\Enumer();
$enumer->convertJson(json: $json, file_path: '/Enums/Test.php', returnType: 'int');

enum Test: int
{
    
   case Guest = 1;

   case Editor = 2;

   case Admin = 3;

   case Owner = 4;

}