Passed
Pull Request — release/4.x (#44)
by Erik
07:43 queued 03:55
created

ErrorLog   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 209
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 40
dl 0
loc 209
ccs 0
cts 81
cp 0
rs 10
c 0
b 0
f 0
wmc 18

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getDateCreated() 0 3 1
A __toString() 0 4 2
A getUa() 0 3 1
A getIp() 0 3 1
A setUrl() 0 4 1
A getMessage() 0 3 1
A __construct() 0 9 1
A getReferer() 0 3 1
A getUrl() 0 3 1
A setStatus() 0 4 1
A getStatus() 0 3 1
A setIp() 0 4 1
A setDateCreated() 0 4 1
A setReferer() 0 4 1
A setUa() 0 4 1
A getId() 0 3 1
A setMessage() 0 4 1
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\UrlBundle\Entity;
7
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * Log entries
12
 *
13
 * @ORM\Entity
14
 * @ORM\Table(name="url_error_log")
15
 */
16
class ErrorLog
17
{
18
    /**
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     * @ORM\Id
21
     * @ORM\Column(type="integer")
22
     */
23
    protected $id;
24
25
    /**
26
     * @ORM\Column(type="integer", nullable=true)
27
     */
28
    protected $status;
29
30
    /**
31
     * @ORM\Column(type="string", length=1024, nullable=true)
32
     */
33
    protected $url;
34
35
    /**
36
     * @ORM\Column(type="string", length=255)
37
     */
38
    protected $ip;
39
40
    /**
41
     * @ORM\Column(type="string", length=1024)
42
     */
43
    protected $ua;
44
45
    /**
46
     * @ORM\Column(type="string", nullable=true)
47
     */
48
    protected $message;
49
50
    /**
51
     * @ORM\Column(type="string", nullable=true)
52
     */
53
    protected $referer;
54
55
    /**
56
     * @ORM\Column(type="datetime", nullable=true)
57
     */
58
    protected $date_created;
59
60
61
    /**
62
     * Create the log entry
63
     *
64
     * @param string $message
65
     * @param \DateTime $date_created
66
     * @param string $referer
67
     * @param string $ua
68
     * @param string $ip
69
     * @param string $url
70
     */
71
    public function __construct($message, $date_created, $referer, $ua, $ip, $url)
72
    {
73
        $this
74
            ->setMessage($message)
75
            ->setDateCreated($date_created)
76
            ->setReferer($referer)
77
            ->setUa($ua)
78
            ->setIp($ip)
79
            ->setUrl($url);
80
    }
81
82
83
    /**
84
     * @return mixed
85
     */
86
    public function getId()
87
    {
88
        return $this->id;
89
    }
90
91
92
    /**
93
     * @return string
94
     */
95
    public function __toString()
96
    {
97
        return (string)$this->message
98
            . ' @ ' . (string)($this->date_created ? $this->date_created->format('YmdHis') : '');
99
    }
100
101
    /**
102
     * @param \DateTime $date_created
103
     * @return ErrorLog
104
     */
105
    public function setDateCreated($date_created)
106
    {
107
        $this->date_created = $date_created;
108
        return $this;
109
    }
110
111
    /**
112
     * @return mixed
113
     */
114
    public function getDateCreated()
115
    {
116
        return $this->date_created;
117
    }
118
119
    /**
120
     * @param string $ip
121
     * @return self
122
     */
123
    public function setIp($ip)
124
    {
125
        $this->ip = $ip;
126
        return $this;
127
    }
128
129
    /**
130
     * @return mixed
131
     */
132
    public function getIp()
133
    {
134
        return $this->ip;
135
    }
136
137
    /**
138
     * @param string $message
139
     * @return self
140
     */
141
    public function setMessage($message)
142
    {
143
        $this->message = $message;
144
        return $this;
145
    }
146
147
    /**
148
     * @return mixed
149
     */
150
    public function getMessage()
151
    {
152
        return $this->message;
153
    }
154
155
    /**
156
     * @param string $referer
157
     * @return self
158
     */
159
    public function setReferer($referer)
160
    {
161
        $this->referer = $referer;
162
        return $this;
163
    }
164
165
    /**
166
     * @return mixed
167
     */
168
    public function getReferer()
169
    {
170
        return $this->referer;
171
    }
172
173
    /**
174
     * @param int $status
175
     * @return self
176
     */
177
    public function setStatus($status)
178
    {
179
        $this->status = $status;
180
        return $this;
181
    }
182
183
    /**
184
     * @return mixed
185
     */
186
    public function getStatus()
187
    {
188
        return $this->status;
189
    }
190
191
    /**
192
     * @param string $ua
193
     * @return self
194
     */
195
    public function setUa($ua)
196
    {
197
        $this->ua = $ua;
198
        return $this;
199
    }
200
201
    /**
202
     * @return mixed
203
     */
204
    public function getUa()
205
    {
206
        return $this->ua;
207
    }
208
209
    /**
210
     * @param string $url
211
     * @return self
212
     */
213
    public function setUrl($url)
214
    {
215
        $this->url = $url;
216
        return $this;
217
    }
218
219
    /**
220
     * @return mixed
221
     */
222
    public function getUrl()
223
    {
224
        return $this->url;
225
    }
226
}
227