-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathide.php
54 lines (43 loc) · 1.1 KB
/
ide.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require __DIR__.'/../vendor/autoload.php';
use Gksh\Bitmask\TinyBitmask;
enum Panel: int
{
case Project = 1 << 0;
case Terminal = 1 << 1;
case SourceControl = 1 << 2;
case Extensions = 1 << 3;
}
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 __construct()
{
$this->panels = Panels::make();
}
public function togglePanel(Panel $panel): self
{
$this->panels->togglePanel($panel);
return $this;
}
}
$ide = (new Ide())
->togglePanel(Panel::Project)
->togglePanel(Panel::Terminal);
dump([
'project' => $ide->panels->isVisible(Panel::Project), // true
'terminal' => $ide->panels->isVisible(Panel::Terminal), // true
'source_control' => $ide->panels->isVisible(Panel::SourceControl), // false
'extensions' => $ide->panels->isVisible(Panel::Extensions), // false
]);