| 1 | <?php |
||
| 5 | class User |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Route notifications for the Email channel. |
||
| 9 | * |
||
| 10 | * @return string |
||
| 11 | */ |
||
| 12 | 5 | public function routeNotificationFor($for) |
|
| 13 | { |
||
| 14 | 5 | if ($for == 'slack') { |
|
| 15 | return $this->routeNotificationForSlack(); |
||
| 16 | } |
||
| 17 | |||
| 18 | 5 | return $this->routeNotificationForEmail(); |
|
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Route notifications for the Email channel. |
||
| 23 | * |
||
| 24 | * @return string |
||
| 25 | */ |
||
| 26 | 5 | public function routeNotificationForEmail() |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Route notifications for the Slack channel. |
||
| 33 | * |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | public function routeNotificationForSlack() |
||
| 40 | } |
||
| 41 |
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: