PHP code example of patr1k / phenum

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

    

patr1k / phenum example snippets



use Patr1k\Phenum;

class Person {
    use Phenum\Enum;
    
    /**
     * @var string
     */
    protected $gender;
    
    const GENDER_MALE        = 'M';
    const GENDER_FEMALE      = 'F';
    const GENDER_UNSPECIFIED = 'U';
    
    /**
     * @return string
     */
    public function getGender() {
        return $this->gender;
    }
    
    /**
     * @param  string $gender
     * @throws Phenum\DomainException
     */
    public function setGender($gender) {
        $this->gender = self::validateEnum($gender, 'GENDER');
    }
}