Skip to content
3 changes: 3 additions & 0 deletions src/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/AutoUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/ChildProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Clipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/Dock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/AutoUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/ChildProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Clipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Dock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/Facades/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fakes/ChildProcessFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, string|null>
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Fakes/WindowManagerFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +13,8 @@

class WindowManagerFake implements WindowManagerContract
{
use Conditionable;

public array $opened = [];

public array $closed = [];
Expand Down
3 changes: 3 additions & 0 deletions src/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/Windows/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -10,6 +11,7 @@

class Window
{
use Conditionable;
use HasDimensions;
use HasUrl {
HasUrl::url as defaultUrl;
Expand Down
2 changes: 2 additions & 0 deletions src/Windows/WindowManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
30 changes: 30 additions & 0 deletions tests/Architecture/ConditionableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Support\Traits\Conditionable;
use Native\Desktop;

use function Pest\version;

describe('architecture', function () {

arch('ensure api is conditionable')
->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', '<');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was failing on prefer-lowest when using pest 2.

I admit that this workaround is a bit janky. But if this runs on the higher versions i think that is enough.

}, 'Test not supporten on Pest < v3');
Loading