Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
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
namespace SebastianBergmann\Environment;
11
 
12
use const DIRECTORY_SEPARATOR;
13
use const PHP_OS;
14
use const PHP_OS_FAMILY;
15
use function defined;
16
 
17
final class OperatingSystem
18
{
19
    /**
20
     * Returns PHP_OS_FAMILY (if defined (which it is on PHP >= 7.2)).
21
     * Returns a string (compatible with PHP_OS_FAMILY) derived from PHP_OS otherwise.
22
     */
23
    public function getFamily(): string
24
    {
25
        if (defined('PHP_OS_FAMILY')) {
26
            return PHP_OS_FAMILY;
27
        }
28
 
29
        if (DIRECTORY_SEPARATOR === '\\') {
30
            return 'Windows';
31
        }
32
 
33
        switch (PHP_OS) {
34
            case 'Darwin':
35
                return 'Darwin';
36
 
37
            case 'DragonFly':
38
            case 'FreeBSD':
39
            case 'NetBSD':
40
            case 'OpenBSD':
41
                return 'BSD';
42
 
43
            case 'Linux':
44
                return 'Linux';
45
 
46
            case 'SunOS':
47
                return 'Solaris';
48
 
49
            default:
50
                return 'Unknown';
51
        }
52
    }
53
}