OS   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 7
c 2
b 1
f 0
dl 0
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A is() 0 3 1
A current() 0 3 1
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