Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function methodNameThatHandlesEvent(object $event): string |
||
20 | { |
||
21 | $methodName = $this->handlesEvents()[get_class($event)] ?? ''; |
||
22 | |||
23 | if ($methodName !== '') { |
||
24 | return $methodName; |
||
25 | } |
||
26 | |||
27 | $wildcardMethod = $this->handlesEvents()['*'] ?? ''; |
||
28 | |||
29 | if ($wildcardMethod !== '') { |
||
30 | return $wildcardMethod; |
||
31 | } |
||
32 | |||
33 | return ''; |
||
34 | } |
||
35 | |||
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: