1. Go to this page and download the library: Download bakame/aide-enums 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/ */
use Bakame\Aide\Enum\Factory;
enum HttpMethod
{
use Factory;
case Get;
case Post;
case Put;
case Head;
case Options;
}
HttpMethod::size(); //returns the number of cases
HttpMethod::isBacked();
HttpMethod::isPure(); // returns the inverse of the `isBacked` method
HttpMethod::names(); // returns a list of all the names in the enumeration
HttpMethod::values(); // returns a list of all the names in the enumeration
HttpMethod::nameOf(404); // returns the name associated with the given value
// or null if it does not exist for the submitted value.
use Bakame\Aide\Enum\Info;
enum HttpMethod: string
{
use Info;
case Get = 'GET';
case Post = 'POST';
case Put = 'PUT';
case Head = 'HEAD';
case Options = 'OPTIONS'
}
use Bakame\Aide\Enum\Hasser;
enum HttpMethod: string
{
use Hasser;
case Get = 'GET';
case Post = 'POST';
case Put = 'PUT';
case Head = 'HEAD';
case Options = 'OPTIONS'
}
HttpMethod::Get->equals(HttpMethod::Post); //returns false
HttpMethod::Get->isOneOf('GET', 'Get', 'get'); //returns true because `Get` is present
HttpMethod::Get->notEquals('get'); //returns true;
HttpMethod::Get->isNotOneOf('Head'); //returns true;
use Bakame\Aide\Enum\Compare;
enum HttpMethod: string
{
use Compare;
case Get = 'GET';
case Post = 'POST';
case Put = 'PUT';
case Head = 'HEAD';
case Options = 'OPTIONS'
}
HttpMethod::toAssociative(); // returns tha associative array
HttpMethod::toJavaScriptObject(); // returns a JavaScript object equivalent code as string
HttpMethod::toJavaScriptClass(); // returns a JavaScript class equivalent code as string
use Bakame\Aide\Enum\Convert;
enum HttpMethod: string
{
use Convert;
case Get = 'GET';
case Post = 'POST';
case Put = 'PUT';
case Head = 'HEAD';
case Options = 'OPTIONS'
}
use Bakame\Aide\Enum\Helper;
enum HttpMethod: string
{
use Helper;
case Get = 'GET';
case Post = 'POST';
case Put = 'PUT';
case Head = 'HEAD';
case Options = 'OPTIONS'
}
enum HttpStatusCode: int
{
case HTTP_OK = 200;
case HTTP_REDIRECTION = 302;
case HTTP_NOT_FOUND = 404;
case HTTP_SERVER_ERROR = 500;
}
use Bakame\Aide\Enum\JavaScriptConverter;
echo JavaScriptConverter::new()->convertToObject(HttpStatusCode::class);