2023-04-22 21:23:12 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\doctor\item;
|
|
|
|
|
|
2023-10-30 00:35:58 +08:00
|
|
|
use SPC\builder\linux\SystemUtil;
|
2023-04-22 21:23:12 +08:00
|
|
|
use SPC\builder\traits\UnixSystemUtilTrait;
|
|
|
|
|
use SPC\doctor\AsCheckItem;
|
|
|
|
|
use SPC\doctor\CheckResult;
|
|
|
|
|
|
|
|
|
|
class OSCheckList
|
|
|
|
|
{
|
|
|
|
|
use UnixSystemUtilTrait;
|
|
|
|
|
|
2024-01-08 23:34:17 +08:00
|
|
|
#[AsCheckItem('if current OS are supported', level: 1000)]
|
2023-04-22 21:23:12 +08:00
|
|
|
public function checkOS(): ?CheckResult
|
|
|
|
|
{
|
2023-12-24 20:17:06 +08:00
|
|
|
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) {
|
|
|
|
|
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
2023-04-22 21:23:12 +08:00
|
|
|
}
|
2023-10-30 00:35:58 +08:00
|
|
|
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
2024-04-02 15:05:49 +08:00
|
|
|
$known_distro = PHP_OS_FAMILY !== 'Linux' || in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
|
2024-01-08 23:34:17 +08:00
|
|
|
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)'));
|
2023-04-22 21:23:12 +08:00
|
|
|
}
|
|
|
|
|
}
|