comparison vendor/sebastian/environment/src/OperatingSystem.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents
children
comparison
equal deleted inserted replaced
1:0b0e5f3b1e83 2:5311817fb629
1 <?php
2 /*
3 * This file is part of sebastian/environment.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 declare(strict_types=1);
12
13 namespace SebastianBergmann\Environment;
14
15 final class OperatingSystem
16 {
17 /**
18 * Returns PHP_OS_FAMILY (if defined (which it is on PHP >= 7.2)).
19 * Returns a string (compatible with PHP_OS_FAMILY) derived from PHP_OS otherwise.
20 */
21 public function getFamily(): string
22 {
23 if (\defined('PHP_OS_FAMILY')) {
24 return PHP_OS_FAMILY;
25 }
26
27 if (DIRECTORY_SEPARATOR === '\\') {
28 return 'Windows';
29 }
30
31 switch (PHP_OS) {
32 case 'Darwin':
33 return 'Darwin';
34
35 case 'DragonFly':
36 case 'FreeBSD':
37 case 'NetBSD':
38 case 'OpenBSD':
39 return 'BSD';
40
41 case 'Linux':
42 return 'Linux';
43
44 case 'SunOS':
45 return 'Solaris';
46
47 default:
48 return 'Unknown';
49 }
50 }
51 }