UserAgent::generate()   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
namespace Sesshin\FingerprintGenerator;
3
4
class UserAgent implements FingerprintGeneratorInterface
5
{
6
    /** @var string */
7
    private $userAgent;
8
9
    /**
10
     * @param string $userAgent
11
     */
12
    public function __construct($userAgent = null)
13
    {
14
        if ($userAgent !== null) {
15
            $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
16
        }
17
18
        $this->userAgent = $userAgent;
19
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function generate()
25
    {
26
        return sha1($this->userAgent);
27
    }
28
}
29