1. Go to this page and download the library: Download gksh/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/ */
gksh / bitmask example snippets
use Gksh\Bitmask\Bitmask;
enum Panel: int
{
case Project = 1;
case Terminal = 2;
case SourceControl = 4;
case Extensions = 8;
}
class Ide
{
public Bitmask $panels;
public function __construct()
{
$this->panels = Bitmask::tiny(); // 8-bit
}
public function togglePanel(Panel $panel): self
{
$this->panels = $this->panels->toggle($panel);
return $this;
}
}
$ide = (new Ide())
->togglePanel(Panel::Project)
->togglePanel(Panel::Terminal);
$ide->panels->has(Panel::Terminal); // true
$ide->panels->has(Panel::Extensions); // false
Bitmask::make() // 32-bit (default)
Bitmask::tiny() // 8-bit, for TINYINT columns
Bitmask::small() // 16-bit, for SMALLINT columns
Bitmask::medium() // 24-bit, for MEDIUMINT columns
$mask = Bitmask::tiny()
->set(Flag::A) // Set a flag
->unset(Flag::B) // Unset a flag
->toggle(Flag::C); // Toggle a flag
$mask->has(Flag::A); // Check if flag is set
$mask->value(); // Get integer value
$mask->size(); // Get Size enum
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.