diff --git a/src/Alert.php b/src/Alert.php index c1586581..35d26fcd 100644 --- a/src/Alert.php +++ b/src/Alert.php @@ -2,10 +2,13 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; class Alert { + use Conditionable; + protected ?string $type = null; protected ?string $title = null; diff --git a/src/App.php b/src/App.php index c3905e8a..7633e308 100644 --- a/src/App.php +++ b/src/App.php @@ -2,11 +2,14 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Phar; class App { + use Conditionable; + public function __construct(protected Client $client) {} public function quit(): void diff --git a/src/AutoUpdater.php b/src/AutoUpdater.php index 477cc6ac..a74bfb45 100644 --- a/src/AutoUpdater.php +++ b/src/AutoUpdater.php @@ -2,10 +2,13 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; class AutoUpdater { + use Conditionable; + public function __construct(protected Client $client) {} public function checkForUpdates(): void diff --git a/src/ChildProcess.php b/src/ChildProcess.php index eac73553..9c691b80 100644 --- a/src/ChildProcess.php +++ b/src/ChildProcess.php @@ -2,11 +2,14 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Native\Desktop\Contracts\ChildProcess as ChildProcessContract; class ChildProcess implements ChildProcessContract { + use Conditionable; + public readonly int $pid; public readonly string $alias; diff --git a/src/Clipboard.php b/src/Clipboard.php index ab023447..4e7d6dc8 100644 --- a/src/Clipboard.php +++ b/src/Clipboard.php @@ -2,10 +2,13 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; class Clipboard { + use Conditionable; + public function __construct(protected Client $client) {} public function clear() diff --git a/src/Dock.php b/src/Dock.php index 9f6bf9c2..6ac67e05 100644 --- a/src/Dock.php +++ b/src/Dock.php @@ -2,11 +2,14 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Native\Desktop\Menu\Menu; class Dock { + use Conditionable; + public function __construct(protected Client $client) {} public function menu(Menu $menu) diff --git a/src/Facades/Alert.php b/src/Facades/Alert.php index 8801da00..7eaefed8 100644 --- a/src/Facades/Alert.php +++ b/src/Facades/Alert.php @@ -14,6 +14,8 @@ * @method static static cancelId(int $cancelId) * @method static int show(string $message) * @method static bool error(string $title, string $message) + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class Alert extends Facade { diff --git a/src/Facades/App.php b/src/Facades/App.php index ababdc5a..42d8c8e8 100644 --- a/src/Facades/App.php +++ b/src/Facades/App.php @@ -22,6 +22,8 @@ * @method static bool openAtLogin(?bool $open = null) * @method static bool isEmojiPanelSupported() * @method static void showEmojiPanel() + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class App extends Facade { diff --git a/src/Facades/AutoUpdater.php b/src/Facades/AutoUpdater.php index c1e8d07f..43b9ff17 100644 --- a/src/Facades/AutoUpdater.php +++ b/src/Facades/AutoUpdater.php @@ -8,6 +8,8 @@ * @method static void checkForUpdates() * @method static void quitAndInstall() * @method static void downloadUpdate() + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class AutoUpdater extends Facade { diff --git a/src/Facades/ChildProcess.php b/src/Facades/ChildProcess.php index 6fe73811..6a12bebf 100644 --- a/src/Facades/ChildProcess.php +++ b/src/Facades/ChildProcess.php @@ -16,6 +16,8 @@ * @method static \Native\Desktop\ChildProcess php(string|array $cmd, string $alias, array $env = null, bool $persistent = false, ?array $iniSettings = null) * @method static \Native\Desktop\ChildProcess artisan(string|array $cmd, string $alias, array $env = null, bool $persistent = false, ?array $iniSettings = null) * @method static void stop(string $alias = null) + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class ChildProcess extends Facade { diff --git a/src/Facades/Clipboard.php b/src/Facades/Clipboard.php index 5d866303..132909a7 100644 --- a/src/Facades/Clipboard.php +++ b/src/Facades/Clipboard.php @@ -9,6 +9,8 @@ * @method static string text($text = null) * @method static string html($html = null) * @method static string|null image($image = null) + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class Clipboard extends Facade { diff --git a/src/Facades/Dock.php b/src/Facades/Dock.php index 69d1518f..43fa7034 100644 --- a/src/Facades/Dock.php +++ b/src/Facades/Dock.php @@ -13,6 +13,8 @@ * @method static void icon(string $Path) * @method static void menu(Menu $menu) * @method static void show() + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class Dock extends Facade { diff --git a/src/Facades/Menu.php b/src/Facades/Menu.php index 4a540f6c..53e162e1 100644 --- a/src/Facades/Menu.php +++ b/src/Facades/Menu.php @@ -41,6 +41,8 @@ * @method static Role hide(?string $label = null) * @method static void create(MenuItem ...$items) * @method static void default() + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class Menu extends Facade { diff --git a/src/Facades/Notification.php b/src/Facades/Notification.php index 2f2ae116..d6e81b2f 100644 --- a/src/Facades/Notification.php +++ b/src/Facades/Notification.php @@ -12,6 +12,8 @@ * @method static static hasReply(string $placeholder = '') * @method static static addAction(string $label) * @method static void show() + * @method static static when($value = null, ?callable $callback = null, ?callable $default = null) + * @method static static unless($value = null, ?callable $callback = null, ?callable $default = null) */ class Notification extends Facade { diff --git a/src/Fakes/ChildProcessFake.php b/src/Fakes/ChildProcessFake.php index 324c0921..b850eb7b 100644 --- a/src/Fakes/ChildProcessFake.php +++ b/src/Fakes/ChildProcessFake.php @@ -3,11 +3,14 @@ namespace Native\Desktop\Fakes; use Closure; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Contracts\ChildProcess as ChildProcessContract; use PHPUnit\Framework\Assert as PHPUnit; class ChildProcessFake implements ChildProcessContract { + use Conditionable; + /** * @var array */ diff --git a/src/Fakes/WindowManagerFake.php b/src/Fakes/WindowManagerFake.php index 0cb80edc..377d37fc 100644 --- a/src/Fakes/WindowManagerFake.php +++ b/src/Fakes/WindowManagerFake.php @@ -4,6 +4,7 @@ use Closure; use Illuminate\Support\Arr; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Native\Desktop\Contracts\WindowManager as WindowManagerContract; use Native\Desktop\Windows\Window; @@ -12,6 +13,8 @@ class WindowManagerFake implements WindowManagerContract { + use Conditionable; + public array $opened = []; public array $closed = []; diff --git a/src/Notification.php b/src/Notification.php index c46a387e..f9a95a65 100644 --- a/src/Notification.php +++ b/src/Notification.php @@ -2,10 +2,13 @@ namespace Native\Desktop; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; class Notification { + use Conditionable; + public ?string $reference = null; protected string $title; diff --git a/src/Windows/Window.php b/src/Windows/Window.php index 133bb687..cfea9515 100644 --- a/src/Windows/Window.php +++ b/src/Windows/Window.php @@ -2,6 +2,7 @@ namespace Native\Desktop\Windows; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Native\Desktop\Concerns\HasDimensions; use Native\Desktop\Concerns\HasUrl; @@ -10,6 +11,7 @@ class Window { + use Conditionable; use HasDimensions; use HasUrl { HasUrl::url as defaultUrl; diff --git a/src/Windows/WindowManager.php b/src/Windows/WindowManager.php index ca2e80d9..5f2ac275 100644 --- a/src/Windows/WindowManager.php +++ b/src/Windows/WindowManager.php @@ -2,12 +2,14 @@ namespace Native\Desktop\Windows; +use Illuminate\Support\Traits\Conditionable; use Native\Desktop\Client\Client; use Native\Desktop\Concerns\DetectsWindowId; use Native\Desktop\Contracts\WindowManager as WindowManagerContract; class WindowManager implements WindowManagerContract { + use Conditionable; use DetectsWindowId; public function __construct(protected Client $client) {} diff --git a/tests/Architecture/ConditionableTest.php b/tests/Architecture/ConditionableTest.php new file mode 100644 index 00000000..1102af2d --- /dev/null +++ b/tests/Architecture/ConditionableTest.php @@ -0,0 +1,30 @@ +expect([ + Desktop\App::class, + Desktop\Dock::class, + Desktop\Alert::class, + Desktop\Clipboard::class, + Desktop\AutoUpdater::class, + Desktop\ChildProcess::class, + Desktop\Notification::class, + Desktop\Menu\Menu::class, + Desktop\Windows\Window::class, + Desktop\Windows\WindowManager::class, + + Desktop\Fakes\ChildProcessFake::class, + Desktop\Fakes\WindowManagerFake::class, + ])->each->toUseTrait(Conditionable::class); + +})->skip(function () { + // Only run test when pest version is at least 3 + return version_compare(version(), '3.0.0', '<'); +}, 'Test not supporten on Pest < v3');