Chris@2: Chris@2: * Chris@2: * For the full copyright and license information, please view the LICENSE Chris@2: * file that was distributed with this source code. Chris@2: */ Chris@2: Chris@2: declare(strict_types=1); Chris@2: Chris@2: namespace SebastianBergmann\Environment; Chris@2: Chris@2: final class OperatingSystem Chris@2: { Chris@2: /** Chris@2: * Returns PHP_OS_FAMILY (if defined (which it is on PHP >= 7.2)). Chris@2: * Returns a string (compatible with PHP_OS_FAMILY) derived from PHP_OS otherwise. Chris@2: */ Chris@2: public function getFamily(): string Chris@2: { Chris@2: if (\defined('PHP_OS_FAMILY')) { Chris@2: return PHP_OS_FAMILY; Chris@2: } Chris@2: Chris@2: if (DIRECTORY_SEPARATOR === '\\') { Chris@2: return 'Windows'; Chris@2: } Chris@2: Chris@2: switch (PHP_OS) { Chris@2: case 'Darwin': Chris@2: return 'Darwin'; Chris@2: Chris@2: case 'DragonFly': Chris@2: case 'FreeBSD': Chris@2: case 'NetBSD': Chris@2: case 'OpenBSD': Chris@2: return 'BSD'; Chris@2: Chris@2: case 'Linux': Chris@2: return 'Linux'; Chris@2: Chris@2: case 'SunOS': Chris@2: return 'Solaris'; Chris@2: Chris@2: default: Chris@2: return 'Unknown'; Chris@2: } Chris@2: } Chris@2: }