1. Go to this page and download the library: Download tlr/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/ */
tlr / enum example snippets
function createNewArticle(string $type) {
// ...
}
class Permission extends Flag
{
protected static $flags = [
'MANAGE_STAFF',
'MANAGE_RESEARCH_PROJECTS',
'VIEW_SECRET_RESEARCH_PROJECTS',
'VIEW_RESEARCH_REPORTS',
];
}
// in some code
$user->permissions = Permission::MANAGE_STAFF();
$reporter->permissions = Permission::VIEW_RESEARCH_REPORTS();
$user->permissions = Permission::MANAGE_STAFF();
$user->permissions = new Permission(0b0001);
$user->permissions = new Permission(1); // although you would probably get this from some user input.
// The following are equivalent:
$user->permissions = Permission::combineFlags([
Permission::VIEW_SECRET_RESEARCH_PROJECTS(),
Permission::VIEW_RESEARCH_REPORTS(),
]);
$user->permissions = new Permission(
Permission::VIEW_SECRET_RESEARCH_PROJECTS()->value() | Permission::VIEW_RESEARCH_REPORTS()
);
$user->permissions = new Permission(0b1100);
$user->permissions = new Permission(12);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.