PHP code example of yungts97 / enum-helpers

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

    

yungts97 / enum-helpers example snippets


use Yungts97\EnumHelpers\Traits\Invokable;
use Yungts97\EnumHelpers\Traits\Contains;
use Yungts97\EnumHelpers\Traits\Random;

enum Status: string
{
    use Invokable, Contains, Random; // add it here

    case Draft = 'draft';
    case Submitted = 'submitted';
    case Pending = 'pending';
    case Approved = 'approved';
    case Rejected = 'rejected';
}

Status::Pending() // "pending"

Status::contains('pending') // true 
Status::contains(Status::Draft) // true
Status::contains(Status::Refund) // false 

Status::random() // Status::Draft 
Status::random(1) // Status::Draft
Status::random(2) // [Status::Draft, Status::Approved]