Conditions | 3 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | protected function replaceUrls() { |
||
21 | |||
22 | $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', |
||
23 | |||
24 | function ($matches) { |
||
25 | if (isset($matches[1]) && isset($matches[2])) |
||
26 | return "<".$matches[1]."|".$matches[2].">"; |
||
27 | else |
||
28 | throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
||
|
|||
29 | }, |
||
30 | |||
31 | $this->text |
||
32 | ); |
||
33 | |||
34 | } |
||
35 | } |
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: