PHP code example of ycecube / php-type-enum

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

    

ycecube / php-type-enum example snippets


 declare(strict_types=1);

use PhpType\Enum;

final class Day extends Enum {

    public static function Monday(): Day
    {
        return new static(0);
    }

    public static function Tuesday(): Day
    {
        return new static(1);
    }

    public static function Wednesday(): Day
    {
        return new static(2);
    }

    // ...
}

function isMonday(Day $day) {
  return $day->equals(Day::Monday());
}

isMonday(Day::Monday()); // Returns true.
isMonday(Day::Tuesday()); // Returns false.