PHP code example of aeviiq / enum
1. Go to this page and download the library: Download aeviiq/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/ */
aeviiq / enum example snippets
final class Foo extends AbstractFlag
{
public const BAR = 1;
public const BAZ = 2;
// ...
}
$foo = new Foo(Foo:BAR);
$foo->contains(new Foo(Foo:BAR)); // True
$foo->contains(new Foo(Foo:BAZ)); // False
$foo->contains(new Bar(Foo::BAR)); // InvalidArgumentException thrown
$foo = new Foo(6); // UnexpectedValueException thrown