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