Skip to content

Commit

Permalink
Consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Dec 19, 2024
1 parent 1a8151f commit 1cf8438
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/Menu/Items/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ class Checkbox extends MenuItem
protected string $type = 'checkbox';

public function __construct(
string $label,
protected ?string $label,
protected bool $isChecked = false,
protected ?string $accelerator = null
) {
$this->label = $label;
}
) {}
}
8 changes: 4 additions & 4 deletions src/Menu/Items/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class Label extends MenuItem
{
public function __construct(string $label)
{
$this->label = $label;
}
public function __construct(
protected ?string $label,
protected ?string $accelerator = null
) {}
}
6 changes: 5 additions & 1 deletion src/Menu/Items/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ class Link extends MenuItem

protected bool $openInBrowser = false;

public function __construct(protected string $url, protected ?string $label, protected ?string $accelerator = null) {}
public function __construct(
protected string $url,
protected ?string $label,
protected ?string $accelerator = null
) {}

public function openInBrowser(bool $openInBrowser = true): self
{
Expand Down
6 changes: 2 additions & 4 deletions src/Menu/Items/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ class Radio extends MenuItem
protected string $type = 'radio';

public function __construct(
string $label,
protected ?string $label,
protected bool $isChecked = false,
protected ?string $accelerator = null
) {
$this->label = $label;
}
) {}
}
5 changes: 4 additions & 1 deletion src/Menu/Items/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class Role extends MenuItem
{
protected string $type = 'role';

public function __construct(protected RolesEnum $role, protected ?string $label = '') {}
public function __construct(
protected RolesEnum $role,
protected ?string $label = ''
) {}

public function toArray(): array
{
Expand Down
9 changes: 7 additions & 2 deletions src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function default(): void
);
}

public function label(string $label): Items\Label
public function label(string $label, ?string $hotkey = null): Items\Label
{
return new Items\Label($label);
return new Items\Label($label, $hotkey);
}

public function checkbox(string $label, bool $checked = false, ?string $hotkey = null): Items\Checkbox
Expand Down Expand Up @@ -162,4 +162,9 @@ public function hide(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::HIDE, $label);
}

public function about(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::ABOUT, $label);
}
}

0 comments on commit 1cf8438

Please sign in to comment.