| Conditions | 3 |
| Paths | 4 |
| Total Lines | 11 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public function getLastPageAttribute(): int |
||
| 38 | { |
||
| 39 | $comments = $this->comment_count; |
||
| 40 | |||
| 41 | if ($this->is_solved) { |
||
| 42 | $comments = $this->comment_count - 1; |
||
| 43 | } |
||
| 44 | $page = ceil($comments / config('xetaravel.pagination.discuss.comment_per_page')); |
||
| 45 | |||
| 46 | return ($page) ? $page : 1; |
||
| 47 | } |
||
| 48 | } |
||
| 49 |
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: