PHP code example of clutz88 / enum-comparison
1. Go to this page and download the library: Download clutz88/enum-comparison 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/ */
clutz88 / enum-comparison example snippets
TestEnum::test->equals('test')
enum TestEnum: string
{
use HasComparisons;
case test = 'test';
}
$value_to_test = 'test';
$enum_value_to_test = TestEnum::test;
TestEnum::test->is($enum_value_to_test); // true
TestEnum::test->is($value_to_test); // false
TestEnum::test->isNot($enum_value_to_test); // false
TestEnum::test->isNot($value_to_test); // true
TestEnum::test->equals($value_to_test); // true
TestEnum::test->equals('testing'); // false
TestEnum::test->notEquals('testing'); // true
$enum_value_to_test->equals($value_to_test); // true