Detect::getBrowser()   B
last analyzed

Complexity

Conditions 7
Paths 7

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 8
c 1
b 0
f 0
nc 7
nop 0
dl 0
loc 12
rs 8.8333
1
<?php
2
namespace GJClasses;
3
4
class Detect
5
{
6
    public function getBrowser()
7
    {
8
        // The order of the below user agent checks matters
9
        // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#browser_name
10
        $agent_string = strtolower($_SERVER['HTTP_USER_AGENT']);
11
        if (strpos($agent_string, 'chromium')) return 'chromium';
12
        if (strpos($agent_string, 'opr/')) return 'opera';
13
        if (strpos($agent_string, 'chrome')) return 'chrome';
14
        if (strpos($agent_string, 'seamonkey')) return 'seamonkey';
15
        if (strpos($agent_string, 'firefox')) return 'firefox';
16
        if (strpos($agent_string, 'version/')) return 'safari';
17
        return '';
18
    }
19
20
}
21