Environment   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 66
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A isWindows() 0 4 1
A isMacOS() 0 4 1
A isSunOS() 0 4 1
A isLinux() 0 4 1
A isArm() 0 4 1
A isArmV7l() 0 4 1
A isArmV6l() 0 4 1
A getArchitecture() 0 4 1
1
<?php
2
namespace Mouf\NodeJsInstaller;
3
4
/**
5
 * A class that returns environment related informations (OS, architecture, etc...)
6
 */
7
class Environment
8
{
9
    /**
10
     * @return bool True if OS is Windows.
11
     */
12
    public static function isWindows()
13
    {
14
        return defined('PHP_WINDOWS_VERSION_BUILD');
15
    }
16
17
    /**
18
     * @return bool True if OS is MacOSX.
19
     */
20
    public static function isMacOS()
21
    {
22
        return PHP_OS === 'Darwin';
23
    }
24
25
    /**
26
     * @return bool True if OS is SunOS.
27
     */
28
    public static function isSunOS()
29
    {
30
        return PHP_OS === 'SunOS';
31
    }
32
33
    /**
34
     * @return bool True if OS is Linux.
35
     */
36
    public static function isLinux()
37
    {
38
        return PHP_OS === 'Linux';
39
    }
40
41
    /**
42
     * @return bool True if processor is Arm.
43
     */
44
    public static function isArm()
45
    {
46
        return strpos(strtolower(php_uname("m")), "arm") === 0;
47
    }
48
49
    /**
50
     * @return bool True if processor is Armv7l.
51
     */
52
    public static function isArmV7l()
53
    {
54
        return php_uname("m") === 'armv7l';
55
    }
56
57
    /**
58
     * @return bool True if processor is Armv6l.
59
     */
60
    public static function isArmV6l()
61
    {
62
        return php_uname("m") === 'armv6l';
63
    }
64
65
    /**
66
     * @return int Returns 32 or 64 depending on supported architecture.
67
     */
68
    public static function getArchitecture()
69
    {
70
        return 8 * PHP_INT_SIZE;
71
    }
72
}
73