1. Go to this page and download the library: Download yaroslavche/bitmask 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 BitMask\EnumBitMask;
enum Permissions
{
case READ;
case WRITE;
case EXECUTE;
}
$mask = new EnumBitMask(Permissions::class);
$mask->set(Permissions::READ);
$mask->set(Permissions::EXECUTE);
$mask->has(Permissions::WRITE); // false
$mask->get(); // 5
enum Flags: int
{
case User = 1; // 0b0001
case Admin = 8; // 0b1000
}
$mask = new EnumBitMask(Flags::class, Flags::User | Flags::Admin);
$mask->get(); // 9