Completed
Pull Request — master (#1596)
by Thomas
32:17
created

UserAgent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 104
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getUserAgent() 0 4 1
A getProperties() 0 4 1
A getChildren() 0 4 1
A getPlatform() 0 4 1
A getEngine() 0 4 1
A getDevice() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
namespace Browscap\Data;
4
5
/**
6
 * represents one useragent section inside of a division as defined in the resources/user-agents directory
7
 */
8
class UserAgent
9
{
10
    /**
11
     * @var string
12
     */
13
    private $userAgent = '';
14
15
    /**
16
     * @var string[]
17
     */
18
    private $properties = [];
19
20
    /**
21
     * @var array[]
22
     */
23
    private $children = [];
24
25
    /**
26
     * @var string|null
27
     */
28
    private $platform;
29
30
    /**
31
     * @var string|null
32
     */
33
    private $engine;
34
35
    /**
36
     * @var string|null
37
     */
38
    private $device;
39
40
    /**
41
     * @param string      $userAgent
42
     * @param string[]    $properties
43
     * @param array[]     $children
44
     * @param string|null $platform
45
     * @param string|null $engine
46
     * @param string|null $device
47
     */
48
    public function __construct(
49
        string $userAgent,
50
        array $properties,
51
        array $children = [],
52
        ?string $platform = null,
53
        ?string $engine = null,
54
        ?string $device = null
55
    ) {
56
        $this->userAgent  = $userAgent;
57
        $this->properties = $properties;
58
        $this->children   = $children;
59
        $this->platform   = $platform;
60
        $this->engine     = $engine;
61
        $this->device     = $device;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getUserAgent() : string
68
    {
69
        return $this->userAgent;
70
    }
71
72
    /**
73
     * @return (string|bool)[]
74
     */
75
    public function getProperties() : array
76
    {
77
        return $this->properties;
78
    }
79
80
    /**
81
     * @return array[]
82
     */
83
    public function getChildren() : array
84
    {
85
        return $this->children;
86
    }
87
88
    /**
89
     * @return string|null
90
     */
91
    public function getPlatform() : ?string
92
    {
93
        return $this->platform;
94
    }
95
96
    /**
97
     * @return string|null
98
     */
99
    public function getEngine() : ?string
100
    {
101
        return $this->engine;
102
    }
103
104
    /**
105
     * @return string|null
106
     */
107
    public function getDevice() : ?string
108
    {
109
        return $this->device;
110
    }
111
}
112