SystemFunctions::isWindowsOperatingSystem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis;
4
5
/**
6
 * Proxy class for system functions.
7
 *
8
 * Class SystemFunctions
9
 * @package BeyondCode\SelfDiagnosis
10
 */
11
class SystemFunctions
12
{
13
    /**
14
     * Performs a shell_exec call. Acts as proxy.
15
     *
16
     * @param string $command
17
     * @return null|string
18
     */
19
    public function callShellExec(string $command): ?string
20
    {
21
        return shell_exec($command);
22
    }
23
24
    /**
25
     * Checks if a function is defined and not disabled.
26
     *
27
     * @param string $function
28
     * @return bool
29
     */
30
    public function isFunctionAvailable(string $function): bool
31
    {
32
        return is_callable($function) && false === stripos(ini_get('disable_functions'), $function);
33
    }
34
35
    /**
36
     * Checks if we are running on a windows operating system.
37
     *
38
     * @return bool
39
     */
40
    public function isWindowsOperatingSystem(): bool
41
    {
42
        return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
43
    }
44
}
45