1 | <?php |
||
15 | class OperatingSystem |
||
16 | { |
||
17 | /** |
||
18 | * @var int |
||
19 | */ |
||
20 | const UID_ROOT = 0; |
||
21 | |||
22 | /** |
||
23 | * Returns true if operating system is |
||
24 | * based on GNU linux. |
||
25 | * |
||
26 | * @return boolean |
||
27 | */ |
||
28 | public static function isLinux() |
||
32 | |||
33 | /** |
||
34 | * Returns true if operating system is |
||
35 | * based on Microsoft Windows. |
||
36 | * |
||
37 | * @return boolean |
||
38 | */ |
||
39 | public static function isWindows() |
||
43 | |||
44 | /** |
||
45 | * Returns true if operating system is |
||
46 | * based on novell netware. |
||
47 | * |
||
48 | * @return boolean |
||
49 | */ |
||
50 | public static function isNetware() |
||
54 | |||
55 | /** |
||
56 | * Returns true if operating system is |
||
57 | * based on apple MacOS. |
||
58 | * |
||
59 | * @return boolean |
||
60 | */ |
||
61 | public static function isMacOs() |
||
65 | |||
66 | /** |
||
67 | * @param string $program |
||
68 | * @return bool |
||
69 | */ |
||
70 | public static function isProgramInstalled($program) |
||
82 | |||
83 | /** |
||
84 | * Home directory of the current user |
||
85 | * |
||
86 | * @return string|false false in case there is no environment variable related to the home directory |
||
87 | */ |
||
88 | public static function getHomeDir() |
||
96 | |||
97 | /** |
||
98 | * Test for Root UID on a POSIX system if posix_getuid() is available. |
||
99 | * |
||
100 | * Returns false negatives if posix_getuid() is not available. |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public static function isRoot() |
||
108 | |||
109 | /** |
||
110 | * get current working directory |
||
111 | * |
||
112 | * @return string the current working directory on success, or false on failure. |
||
113 | */ |
||
114 | public static function getCwd() |
||
118 | |||
119 | /** |
||
120 | * Retrieve path to php binary |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public static function getPhpBinary() |
||
137 | |||
138 | /** |
||
139 | * @return bool |
||
140 | */ |
||
141 | public static function isBashCompatibleShell() |
||
148 | } |
||
149 |
If you suppress an error, we recommend checking for the error condition explicitly: