UserAgent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 25
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A generate() 0 4 1
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