Completed
Push — master ( f47ecb...1c0a88 )
by Roni
14:50
created

BaseAuditLog::getImpersonatingUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the XiideaEasyAuditBundle package.
5
 *
6
 * (c) Xiidea <http://www.xiidea.net>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Xiidea\EasyAuditBundle\Entity;
13
14
use Psr\Log\InvalidArgumentException;
15
use Psr\Log\LogLevel;
16
use Xiidea\EasyAuditBundle\Traits\EntityHydrationMethod;
17
18
abstract class BaseAuditLog
19
{
20
    use EntityHydrationMethod;
21
22
    /**
23
     * @var string
24
     */
25
    protected $typeId;
26
27
    /**
28
     * @var string
29
     */
30
    protected $type;
31
32
    /**
33
     * @var string
34
     */
35
    protected $description;
36
37
    /**
38
     * @var \DateTime
39
     */
40
    protected $eventTime;
41
42
    protected $user;
43
44
    protected $impersonatingUser;
45
46
    /**
47
     * @var String
48
     */
49
    protected $ip;
50
51
    /**
52
     * @var String
53
     */
54
    protected $level = LogLevel::INFO;
55
56
    public function getUser()
57
    {
58
        return $this->user;
59
    }
60
61
    public function setUser($user)
62
    {
63
        $this->user = $user;
64
    }
65
66
    /**
67
     * @return \DateTime
68
     */
69
    final public function getEventTime()
70
    {
71
        return $this->eventTime;
72
    }
73
74
    /**
75
     * @param \DateTime $eventTime
76
     */
77
    final public function setEventTime(\DateTime $eventTime)
78
    {
79
        $this->eventTime = $eventTime;
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getType()
86
    {
87
        return $this->type;
88
    }
89
90
    /**
91
     * @param string $type
92
     */
93
    public function setType($type)
94
    {
95
        $this->type = $type;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getDescription()
102
    {
103
        return $this->description;
104
    }
105
106
    /**
107
     * @param string $description
108
     */
109
    public function setDescription($description)
110
    {
111
        $this->description = $description;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getTypeId()
118
    {
119
        return $this->typeId;
120
    }
121
122
    /**
123
     * @param string $typeId
124
     *
125
     * @return $this
126
     */
127
    public function setTypeId($typeId)
128
    {
129
        $this->typeId = $typeId;
130
131
        return $this;
132
    }
133
134
    /**
135
     * @return String
136
     */
137
    public function getIp()
138
    {
139
        return $this->ip;
140
    }
141
142
    /**
143
     * @param String $ip
144
     *
145
     * @return $this
146
     */
147
    public function setIp($ip)
148
    {
149
        $this->ip = $ip;
150
151
        return $this;
152
    }
153
154
    /**
155
     * @return string
156
     */
157
    final public function getLevel()
158
    {
159
        return $this->level;
160
    }
161
162
    /**
163
     * @param string $level
164
     * @return $this
165
     */
166
    final public function setLevel($level)
167
    {
168
        if (!in_array(strtolower($level), $this->getAllowedLevel())) {
169
            throw new InvalidArgumentException();
170
        }
171
172
        $this->level = $level;
173
174
        return $this;
175
    }
176
177
    private function getAllowedLevel()
178
    {
179
        $oClass = new \ReflectionClass ('Psr\Log\LogLevel');
180
181
        return $oClass->getConstants();
182
    }
183
184
    /**
185
     * @return mixed
186
     */
187
    public function getImpersonatingUser()
188
    {
189
        return $this->impersonatingUser;
190
    }
191
192
    /**
193
     * @param mixed $impersonatingUser
194
     */
195
    public function setImpersonatingUser($impersonatingUser)
196
    {
197
        $this->impersonatingUser = $impersonatingUser;
198
    }
199
}
200