Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function __construct($text) |
||
26 | { |
||
27 | $lines = explode("\n", trim($text)); |
||
28 | $_firstLine = array_shift($lines); |
||
29 | preg_match( |
||
30 | '/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (.*?): (.*)/', |
||
31 | $_firstLine, |
||
32 | $matches |
||
33 | ); |
||
34 | $this->_time = $matches[1]; |
||
|
|||
35 | $this->_type = $matches[2]; |
||
36 | $this->_message = trim($matches[3]); |
||
37 | if (empty($this->_message)) { |
||
38 | $this->_message = array_shift($lines); |
||
39 | } |
||
40 | $this->_detail = implode($lines, '<br>'); |
||
41 | } |
||
42 | |||
83 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: