Skip to content

Commit

Permalink
Type hints and consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Nov 20, 2024
1 parent 1c8931e commit c6cc7e0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 33 deletions.
39 changes: 38 additions & 1 deletion src/Facades/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,46 @@
namespace Native\Laravel\Facades;

use Illuminate\Support\Facades\Facade;
use Native\Laravel\Menu\Items\Checkbox;
use Native\Laravel\Menu\Items\GoToUrl;
use Native\Laravel\Menu\Items\Label;
use Native\Laravel\Menu\Items\Link;
use Native\Laravel\Menu\Items\Radio;
use Native\Laravel\Menu\Items\Role;
use Native\Laravel\Menu\Items\Separator;

/**
* @method static void create()
* @method static \Native\Laravel\Menu\Menu make(MenuItem ...$items)
* @method static Checkbox checkbox(string $label, bool $checked = false, ?string $hotkey = null)
* @method static GoToLink goToUrl(string $url, string $label = null, ?string $hotkey = null)
* @method static GoToLink goToRoute(string $url, string $label = null, ?string $hotkey = null)
* @method static Label label(string $label)
* @method static Link link(string $url, string $label = null, ?string $hotkey = null)
* @method static Radio radio(string $label, bool $checked = false, ?string $hotkey = null)
* @method static Role app()
* @method static Role file()
* @method static Role edit()
* @method static Role view()
* @method static Role window()
* @method static Role help()
* @method static Role window()
* @method static Role fullscreen()
* @method static Role separator()
* @method static Role devTools()
* @method static Role undo()
* @method static Role redo()
* @method static Role cut()
* @method static Role copy()
* @method static Role paste()
* @method static Role pasteAndMatchStyle()
* @method static Role reload()
* @method static Role minimize()
* @method static Role close()
* @method static Role quit()
* @method static Role help()
* @method static Role hide()
* @method static void create(MenuItem ...$items)
* @method static void default()
*/
class Menu extends Facade
{
Expand Down
64 changes: 32 additions & 32 deletions src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ public function app(): Items\Role
return new Items\Role(RolesEnum::APP_MENU);
}

public function file($label = 'File'): Items\Role
public function file(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::FILE_MENU, $label);
}

public function edit($label = 'Edit'): Items\Role
public function edit(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::EDIT_MENU, $label);
}

public function view($label = 'View'): Items\Role
public function view(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::VIEW_MENU, $label);
}

public function window($label = 'Window'): Items\Role
public function window(?string $label = null): Items\Role
{
return new Items\Role(RolesEnum::WINDOW_MENU, $label);
}
Expand All @@ -99,73 +99,73 @@ public function separator(): Items\Separator
return new Items\Separator;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit c6cc7e0

Please sign in to comment.