Total Complexity | 16 |
Total Lines | 153 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class LogEntry |
||
8 | { |
||
9 | /** |
||
10 | * @var string $message |
||
11 | */ |
||
12 | protected $message; |
||
13 | |||
14 | /** |
||
15 | * @var string $code |
||
16 | */ |
||
17 | protected $code; |
||
18 | |||
19 | /** |
||
20 | * @var string $line |
||
21 | */ |
||
22 | protected $line; |
||
23 | |||
24 | /** |
||
25 | * @var string $file |
||
26 | */ |
||
27 | protected $file; |
||
28 | |||
29 | /** |
||
30 | * @var string $trace |
||
31 | */ |
||
32 | protected $trace; |
||
33 | |||
34 | public function info($message) |
||
35 | { |
||
36 | $this->message = $message; |
||
37 | |||
38 | return $this; |
||
39 | } |
||
40 | |||
41 | public function error(\Exception $exception) |
||
42 | { |
||
43 | $this->message = $exception->getMessage(); |
||
44 | $this->code = $exception->getCode(); |
||
45 | $this->line = $exception->getLine(); |
||
46 | $this->file = $exception->getFile(); |
||
47 | $this->trace = $exception->getTraceAsString(); |
||
48 | |||
49 | return $this; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return false|string |
||
54 | */ |
||
55 | public function toJson() |
||
56 | { |
||
57 | $response = $this->jsonSerialize(); |
||
58 | |||
59 | return json_encode($response); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return array |
||
64 | */ |
||
65 | public function jsonSerialize() |
||
66 | { |
||
67 | $arrayProperties = array(); |
||
68 | |||
69 | foreach ($this as $key => $value) { |
||
70 | if (!empty($value)) { |
||
71 | $arrayProperties[Str::toSnakeCase($key)] = $value; |
||
72 | } |
||
73 | } |
||
74 | |||
75 | return $arrayProperties; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * GETTERS Y SETTERS |
||
80 | */ |
||
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getMessage() |
||
86 | { |
||
87 | return $this->message; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @param string $message |
||
92 | */ |
||
93 | public function setMessage($message) |
||
94 | { |
||
95 | $this->message = $message; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getCode() |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @param string $code |
||
108 | */ |
||
109 | public function setCode($code) |
||
110 | { |
||
111 | $this->code = $code; |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @return string |
||
116 | */ |
||
117 | public function getLine() |
||
118 | { |
||
119 | return $this->line; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @param string $line |
||
124 | */ |
||
125 | public function setLine($line) |
||
126 | { |
||
127 | $this->line = $line; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @return string |
||
132 | */ |
||
133 | public function getFile() |
||
134 | { |
||
135 | return $this->file; |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @param string $file |
||
140 | */ |
||
141 | public function setFile($file) |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getTrace() |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param string $trace |
||
156 | */ |
||
157 | public function setTrace($trace) |
||
160 | } |
||
161 | } |
||
162 |