1. Go to this page and download the library: Download codekandis/phlags 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/ */
codekandis / phlags example snippets
class Permissions extends AbstractFlagable
{
public const int READ = 1;
public const int WRITE = 2;
public const int EXECUTE = 4;
}
1
Permissions::READ
new Permissions( 1 )
new Permissions( Permission::READ )
new Permissions( 'READ' );
new Permission( 1 | 'READ' | new Permissions( READ ) )
// with the default flag 'Permissions::NONE' (inherited from `FlagableInterface::NONE`)
$permissions = new Permissions();
// with a single flag
$permissions = new Permissions( Permissions::READ );
// with multiple flags
$permissions = new Permissions( Permissions::READ | Permissions::WRITE );
// with another flagable
$permissions = new Permissions( new Permissions( Permissions::READ ) );
// with string representations
$permissions = new ( 'READ' );
$permissions = new ( 'READ|WRITE' );
$permissions = new ( 'READ|WRITE|EXECUTE' );
// with mixed string representations
$permissions = new ( '1' );
$permissions = new ( '1|2' );
$permissions = new ( '1|WRITE|4' );
class Permissions extends AbstractFlagable SomeTraitfulInterface
{
use SomeTraitfulExtension;
public const int READ = 1;
public const int WRITE = 2;
public const int EXECUTE = 4;
}