Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class Webhook extends HttpApi |
||
16 | { |
||
17 | /** |
||
18 | * @param string $domain |
||
19 | * |
||
20 | * @return IndexResponse |
||
21 | */ |
||
22 | public function index($domain) |
||
29 | |||
30 | /** |
||
31 | * @param string $domain |
||
32 | * @param string $webhook |
||
33 | * |
||
34 | * @return ShowResponse |
||
35 | */ |
||
36 | View Code Duplication | public function show($domain, $webhook) |
|
44 | |||
45 | /** |
||
46 | * @param string $domain |
||
47 | * @param string $id |
||
48 | * @param string $url |
||
49 | * |
||
50 | * @return CreateResponse |
||
51 | */ |
||
52 | View Code Duplication | public function create($domain, $id, $url) |
|
67 | |||
68 | /** |
||
69 | * @param string $domain |
||
70 | * @param string $id |
||
71 | * @param string $url |
||
72 | * |
||
73 | * @return UpdateResponse |
||
74 | */ |
||
75 | public function update($domain, $id, $url) |
||
89 | |||
90 | /** |
||
91 | * @param string $domain |
||
92 | * @param string $id |
||
93 | * |
||
94 | * @return DeleteResponse |
||
95 | */ |
||
96 | View Code Duplication | public function delete($domain, $id) |
|
105 | } |
||
106 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.