OS::is()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace SwooleTW\Http\Helpers;
4
5
use Illuminate\Support\Str;
6
7
/**
8
 * Class OS
9
 */
10
final class OS
11
{
12
    /**
13
     * Mac OS
14
     *
15
     * @const string
16
     */
17
    public const MAC_OS = 'dar';
18
19
    /**
20
     * Linux
21
     *
22
     * @const string
23
     */
24
    public const LINUX = 'lin';
25
26
    /**
27
     * Linux
28
     *
29
     * @const string
30
     */
31
    public const WIN = 'win';
32
33
    /**
34
     * Cygwin
35
     *
36
     * @const string
37
     */
38
    public const CYGWIN = 'cyg';
39
40
    /**
41
     * Returns true if current OS in types
42
     *
43
     * @param string ...$types
44
     *
45
     * @return bool
46
     */
47
    public static function is(string ...$types): bool
48
    {
49
        return Str::contains(static::current(), $types);
50
    }
51
52
    /**
53
     * Current OS
54
     *
55
     * @return string
56
     */
57
    public static function current(): string
58
    {
59
        return Str::substr(Str::lower(PHP_OS), 0, 3);
60
    }
61
}
62