| Conditions | 3 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function commentAsGuest(array $fields) |
||
| 24 | { |
||
| 25 | if ( ! $this->allow_comments || ! $this->allow_guest_comments) { |
||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | return $this->comments()->create([ |
||
| 30 | 'content' => $fields->content, |
||
| 31 | 'user_id' => null, |
||
| 32 | 'email' => $comment->email, |
||
| 33 | 'author' => $comment->author, |
||
| 34 | 'is_approved' => false, |
||
| 35 | ]); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |
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: