Skip to content

Commit efd4da8

Browse files
committed
refactor: extract isWindowsPlatform method in Herd class and update related logic
1 parent cf4a214 commit efd4da8

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/Install/Herd.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Laravel\Boost\Install;
66

7+
use Laravel\Boost\Install\Enums\Platform;
8+
79
class Herd
810
{
911
public function isInstalled(): bool
1012
{
11-
$isWindows = PHP_OS_FAMILY === 'Windows';
12-
13-
if (! $isWindows) {
13+
if ($this->isWindowsPlatform()) {
1414
return file_exists('/Applications/Herd.app/Contents/MacOS/Herd');
1515
}
1616

@@ -24,7 +24,7 @@ public function isMcpAvailable(): bool
2424

2525
public function getHomePath(): string
2626
{
27-
if (PHP_OS_FAMILY === 'Windows') {
27+
if ($this->isWindowsPlatform()) {
2828
if (! isset($_SERVER['HOME'])) {
2929
$_SERVER['HOME'] = $_SERVER['USERPROFILE'];
3030
}
@@ -37,12 +37,15 @@ public function getHomePath(): string
3737

3838
public function mcpPath(): string
3939
{
40-
$isWindows = PHP_OS_FAMILY === 'Windows';
41-
42-
if ($isWindows) {
40+
if ($this->isWindowsPlatform()) {
4341
return $this->getHomePath().'/.config/herd/bin/herd-mcp.phar';
4442
}
4543

4644
return $this->getHomePath().'/Library/Application Support/Herd/bin/herd-mcp.phar';
4745
}
46+
47+
public function isWindowsPlatform(): bool
48+
{
49+
return Platform::current() === Platform::Windows;
50+
}
4851
}

tests/Unit/Install/HerdTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,15 @@ function getHerdTestTempDir(): string
175175

176176
expect($herd->isInstalled())->toBeFalse();
177177
})->onlyOnWindows();
178+
179+
test('isWindowsPlatform returns true on Windows', function () {
180+
$herd = new Herd();
181+
182+
expect($herd->isWindowsPlatform())->toBeTrue();
183+
})->onlyOnWindows();
184+
185+
test('isWindowsPlatform returns false on non-Windows platforms', function () {
186+
$herd = new Herd();
187+
188+
expect($herd->isWindowsPlatform())->toBeFalse();
189+
})->skipOnWindows();

0 commit comments

Comments
 (0)