GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 17ecf2...9b721d )
by w3l
10:14 queued 08:31
created

Browser::isClientBrowserGoogleChrome()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
rs 9.2
cc 4
eloc 7
nc 3
nop 0
1
<?php
2
/**
3
 * Browser.php
4
 */
5
namespace w3l\Holt45;
6
7
/**
8
 * Get data from the browser/user.
9
 */
10
trait Browser
11
{
12
    /**
13
     * Get client ip-address
14
     *
15
     * @return null|string User ip-address
16
     */
17
    public static function getClientIpAddress($fallbackReturn = null)
18
    {
19
        if (getenv('HTTP_CLIENT_IP')) {
20
            return getenv('HTTP_CLIENT_IP');
21
        } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
22
            return getenv('HTTP_X_FORWARDED_FOR');
23
        } elseif (getenv('HTTP_X_FORWARDED')) {
24
            return getenv('HTTP_X_FORWARDED');
25
        } elseif (getenv('HTTP_FORWARDED_FOR')) {
26
            return getenv('HTTP_FORWARDED_FOR');
27
        } elseif (getenv('HTTP_FORWARDED')) {
28
            return getenv('HTTP_FORWARDED');
29
        } elseif (getenv('REMOTE_ADDR')) {
30
            return getenv('REMOTE_ADDR');
31
        }
32
        /* Unknown IP */
33
        return $fallbackReturn;
34
    }
35
36
    /**
37
     * Get client operating system
38
     *
39
     * NOTICE: HTTP_USER_AGENT is easily spoofed. Don't trust this data.
40
     *
41
     * @used-by: Holt45::kbdSymbol()
42
     *
43
     * @return null|string User operating system(win|mac|linux)
44
     */
45
    public static function getClientOperatingSystem()
46
    {
47
        if (getenv('HTTP_USER_AGENT')) {
48
            $userAgent = getenv('HTTP_USER_AGENT');
49
50
            if (preg_match('/linux/i', $userAgent)) {
51
                return 'linux';
52
            } elseif (preg_match('/macintosh|mac os x/i', $userAgent)) {
53
                return'mac';
54
            } elseif (preg_match('/windows|win32/i', $userAgent)) {
55
                return 'windows';
56
            }
57
        }
58
        
59
        return null;
60
    }
61
62
    /**
63
     * Get client browser
64
     *
65
     * NOTICE: HTTP_USER_AGENT is easily spoofed. Don't trust this data.
66
     *
67
     * @return null|string User browser(Internet Explorer|Camino|Firefox|Safari|Chrome|Konqueror|Opera)
68
     */
69
    public static function getClientBrowser()
70
    {
71
        if (getenv('HTTP_USER_AGENT')) {
72
            
73
            $userAgent = getenv('HTTP_USER_AGENT');
74
            
75
            if ((
76
                preg_match('/MSIE/i', $userAgent) ||
77
                preg_match('/Trident/i', $userAgent)
78
                ) &&
79
                !preg_match('/Opera/i', $userAgent)) {
80
                return 'Internet Explorer';
81
            } elseif (preg_match('/Camino/i', $userAgent)) {
82
                return "Camino";
83
            } elseif (preg_match('/Firefox/i', $userAgent)) {
84
                return "Firefox";
85
            } elseif (preg_match('/Safari/i', $userAgent)) {
86
                return "Safari";
87
            } elseif (preg_match('/Chrome/i', $userAgent)) {
88
                return "Chrome";
89
            } elseif (preg_match('/Konqueror/i', $userAgent)) {
90
                return "Konqueror";
91
            } elseif (preg_match('/Opera/i', $userAgent)) {
92
                return "Opera";
93
            }
94
        }
95
        
96
        return null;
97
    }
98
    
99
    
100
    /**
101
     * Check if browser is Google Chrome and not one of the browsers derived from Google Chrome.
102
     *
103
     * NOTICE: HTTP_USER_AGENT is easily spoofed. Don't trust this data.
104
     *
105
     * @return bool
106
     */
107
    public static function isClientBrowserGoogleChrome()
108
    {
109
        if (getenv('HTTP_USER_AGENT')) {
110
            
111
            $userAgent = getenv('HTTP_USER_AGENT');
112
            
113
            if (preg_match('/(Chrome|CriOS)\//i', $userAgent) &&
114
                !preg_match('/(Aviator|brave|ChromePlus|coc_|Dragon|Edge|Flock|Iron|Kinza|Maxthon|MxNitro|Nichrome|OPR|Perk|Rockmelt|Seznam|Sleipnir|Spark|UBrowser|Vivaldi|WebExplorer|YaBrowser)/i', $userAgent)) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 213 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
115
                return true;
116
            }
117
        }
118
        return false;
119
    }
120
}
121