CrossjoinBrowscap::getVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * CSP
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2014 Kenji Suzuki
8
 * @link       https://github.com/kenjis/php-csp-nonce-source
9
 */
10
11
namespace Kenjis\Csp\Browser;
12
13
/**
14
 * Browser Detector using Crossjoin\Browscap
15
 */
16
class CrossjoinBrowscap implements AdapterInterface
17
{
18
    /**
19
     * @var stdClass
20
     */
21
    private $browser;
22
23
    /**
24
     * @param string $userAgent user agent string
25
     */
26
    public function __construct($userAgent)
27
    {
28
        $browscap = new \Crossjoin\Browscap\Browscap();
29
        $this->browser = $browscap->getBrowser($userAgent)->getData();
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getName()
36
    {
37
        return $this->browser->browser;
38
    }
39
40
    /**
41
     * @return int
42
     */
43
    public function getVersion()
44
    {
45
        return (int) $this->browser->version;
46
    }
47
}
48