PHP code example of gksh / bitmask
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
enum Panel: int
{
case Project = 1;
case Terminal = 2;
case SourceControl = 4;
case Extensions = 8;
}
class Panels extends TinyBitmask
{
public function isVisible(Panel $panel): bool
{
return $this->has($panel->value);
}
public function togglePanel(Panel $panel): Panels
{
return $this->toggle($panel->value);
}
}
class Ide
{
public Panels $panels;
public function togglePanel(Panel $panel): self
{
$this->panels->togglePanel($panel);
return $this;
}
}
$ide = (new Ide())
->togglePanel(Panel::Project)
->togglePanel(Panel::Terminal);
$ide->panels->isVisible(Panel::Terminal); // true
$ide->panels->isVisible(Panel::Extensions); // false