PHP code example of extalion / php-enum

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

    

extalion / php-enum example snippets


/**
 * @method static RequestMethod get()
 * @method static RequestMethod post()
 */
final class RequestMethod extends \Enum
{
    const VALUES = [
        'get' => 1,
        'post' => 2
    ];
}

function request(string $url, RequestMethod $method, array $data = [])
{
    // ...

    if ($method === RequestMethod::post()) {
        \curl_setopt($ch, \CURLOPT_POST, 1);
        \curl_setopt($ch, \CURLOPT_POSTFIELDS, $data);
    }

    // ...
}

php -d zend.assertions=1 test.php
bash
composer install extalion/php-enum