PHP code example of natepisarski / random-enum

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

    

natepisarski / random-enum example snippets


use Natepisarski\RandomEnum\RandomEnum

enum Days: string {
  use RandomEnum;
 
  case Sunday = 'sunday';
  case Monday = 'monday';
  case Tuesday = 'tuesday';
}

Days::randomCase(); // === Days::Sunday

Days::randomValue(); // === 'sunday'

Days::randomCaseArray(count: 3, allowRepeats: false); // === [Days::Tuesday, Days::Monday, Days::Sunday]

Days::randomValueArray(count: 3, allowRepeats: true); // === ['tuesday', 'monday', 'sunday']