Skip to content

Commit add4cc9

Browse files
committed
transpile: regenerate MachineInformation for ?? match fix
Constructor now honours the provided $operatingSystem/$architecture arguments instead of always auto-detecting the host.
1 parent ddd4285 commit add4cc9

1 file changed

Lines changed: 33 additions & 25 deletions

File tree

src/Utils/MachineInformation.php

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,41 @@ class MachineInformation
2424

2525
public function __construct(?string $operatingSystem = null, ?string $architecture = null)
2626
{
27-
switch (strtolower(substr(php_uname('s'), 0, 3))) {
28-
case 'dar':
29-
$this->operatingSystem = self::OS_DARWIN;
30-
break;
31-
case 'lin':
32-
$this->operatingSystem = self::OS_LINUX;
33-
break;
34-
case 'win':
35-
$this->operatingSystem = self::OS_WINDOWS;
36-
break;
37-
default:
38-
$this->operatingSystem = self::OS_UNKNOWN;
39-
break;
27+
if ($operatingSystem !== null) {
28+
$this->operatingSystem = $operatingSystem;
29+
} else {
30+
switch (strtolower(substr(php_uname('s'), 0, 3))) {
31+
case 'dar':
32+
$this->operatingSystem = self::OS_DARWIN;
33+
break;
34+
case 'lin':
35+
$this->operatingSystem = self::OS_LINUX;
36+
break;
37+
case 'win':
38+
$this->operatingSystem = self::OS_WINDOWS;
39+
break;
40+
default:
41+
$this->operatingSystem = self::OS_UNKNOWN;
42+
break;
43+
}
4044
}
4145

42-
switch (strtolower(php_uname('m'))) {
43-
case 'x86_64':
44-
case 'amd64':
45-
$this->architecture = self::ARCH_X86_64;
46-
break;
47-
case 'arm64':
48-
case 'aarch64':
49-
$this->architecture = self::ARCH_ARM64;
50-
break;
51-
default:
52-
$this->architecture = self::ARCH_UNKNOWN;
53-
break;
46+
if ($architecture !== null) {
47+
$this->architecture = $architecture;
48+
} else {
49+
switch (strtolower(php_uname('m'))) {
50+
case 'x86_64':
51+
case 'amd64':
52+
$this->architecture = self::ARCH_X86_64;
53+
break;
54+
case 'arm64':
55+
case 'aarch64':
56+
$this->architecture = self::ARCH_ARM64;
57+
break;
58+
default:
59+
$this->architecture = self::ARCH_UNKNOWN;
60+
break;
61+
}
5462
}
5563
}
5664

0 commit comments

Comments
 (0)