Total Complexity | 6 |
Total Lines | 91 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | class CakeLogEntry |
||
19 | { |
||
20 | /** |
||
21 | * Time |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $_time; |
||
26 | |||
27 | /** |
||
28 | * Time |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $_type; |
||
33 | |||
34 | /** |
||
35 | * Message |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $_message; |
||
40 | |||
41 | /** |
||
42 | * Detail |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $_detail; |
||
47 | |||
48 | /** |
||
49 | * Constructor |
||
50 | * |
||
51 | * @param string $text log entry text |
||
52 | */ |
||
53 | public function __construct($text) |
||
54 | { |
||
55 | $lines = explode("\n", trim($text)); |
||
56 | $_firstLine = array_shift($lines); |
||
57 | preg_match( |
||
58 | '/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (.*?): (.*)/', |
||
59 | $_firstLine, |
||
60 | $matches |
||
61 | ); |
||
62 | $this->_time = $matches[1]; |
||
63 | $this->_type = $matches[2]; |
||
64 | $this->_message = trim($matches[3]); |
||
65 | if (empty($this->_message)) { |
||
66 | $this->_message = array_shift($lines); |
||
67 | } |
||
68 | $this->_detail = implode($lines, '<br>'); |
||
|
|||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Gets log entry time |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function time() |
||
77 | { |
||
78 | return $this->_time; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Gets log entry type |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function type() |
||
87 | { |
||
88 | return $this->_type; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Gets log entry message |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function message() |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Gets log entry details |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function details() |
||
109 | } |
||
110 | } |
||
111 |