Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function collectImages() |
||
21 | { |
||
22 | // For update topic logic |
||
23 | $this->images()->delete(); |
||
24 | |||
25 | $links = get_image_links($this->body); |
||
26 | |||
27 | if (count($links)) { |
||
28 | $link = array_shift($links); |
||
29 | $data = [ |
||
30 | 'topic_id' => $this->id, |
||
31 | 'link' => $link, |
||
32 | ]; |
||
33 | Image::updateOrCreate($data, $data); |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 |
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: