Completed
Push — master ( 300a85...802a6c )
by François
03:18
created

UserAgent::getAgentName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Bouncer package.
5
 *
6
 * (c) François Hodierne <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bouncer\Resource;
13
14
use Bouncer\Resource;
15
16
class UserAgent extends Resource
17
{
18
19
    /**
20
     * The unique id
21
     *
22
     * @var string
23
     */
24
    protected $id;
25
26
    /**
27
     * Type: browser or robot
28
     *
29
     * @var string
30
     */
31
    protected $type;
32
33
    /**
34
     * Agent
35
     *
36
     * @var object
37
     */
38
    protected $agent;
39
40
    /**
41
     * System
42
     *
43
     * @var object
44
     */
45
    protected $system;
46
47
    /*
48
     * @return string|null
49
     */
50
    public function getId()
51
    {
52
        return $this->id;
53
    }
54
55
    /*
56
     * @param string $id
57
     */
58
    public function setId($id)
59
    {
60
        $this->id = $id;
61
    }
62
63
    /*
64
     * @return string|null
65
     */
66
    public function getType()
67
    {
68
        return $this->type;
69
    }
70
71
    /*
72
     * @param string $type robot|browser
73
     */
74
    public function setType($type)
75
    {
76
        $this->type = $type;
77
    }
78
79
    /*
80
     * @return object|null
81
     */
82
    public function getAgent()
83
    {
84
        return $this->agent;
85
    }
86
87
    /*
88
     * @param object|array $agent
89
     */
90
    public function setAgent($agent)
91
    {
92
        if (is_object($agent)) {
93
            $this->agent = $agent;
94
        } elseif (is_array($agent)) {
95
            $this->agent = new UserAgentPart($agent);
96
        }
97
    }
98
99
    /*
100
     * @return string|null
101
     */
102
    public function getAgentName()
103
    {
104
        $agent = $this->getAgent();
105
        if ($agent) {
106
            return $agent->getName();
107
        }
108
    }
109
110
    /*
111
     * @return object|null
112
     */
113
    public function getSystem()
114
    {
115
        return $this->system;
116
    }
117
118
    /*
119
     * @param object|array $system
120
     */
121
    public function setSystem($system)
122
    {
123
        if (is_object($system)) {
124
            $this->system = $system;
125
        } elseif (is_array($system)) {
126
            $this->system = new UserAgentPart($system);
127
        }
128
    }
129
130
    /*
131
     * @return string|null
132
     */
133
    public function getSystemName()
134
    {
135
        $system = $this->getSystem();
136
        if ($system) {
137
            return $system->getName();
138
        }
139
    }
140
141
}
142