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 |
||
28 | class Relation extends AbstractAPI |
||
29 | { |
||
30 | const API_DEVICE_BINDPAGE = 'https://api.weixin.qq.com/shakearound/device/bindpage'; |
||
31 | const API_RELATION_SEARCH = 'https://api.weixin.qq.com/shakearound/relation/search'; |
||
32 | |||
33 | |||
34 | /** |
||
35 | * Bind pages for device. |
||
36 | * |
||
37 | * @param array $device_identifier |
||
38 | * @param array $page_ids |
||
39 | * |
||
40 | * @return \EasyWeChat\Support\Collection |
||
41 | */ |
||
42 | public function bindPage(array $device_identifier, array $page_ids) |
||
51 | |||
52 | /** |
||
53 | * Get page_ids by device_id. |
||
54 | * |
||
55 | * @param array $device_identifier |
||
56 | * @param boolean $raw |
||
57 | * |
||
58 | * @return array|\EasyWeChat\Support\Collection |
||
59 | */ |
||
60 | public function getPageByDeviceId(array $device_identifier, $raw = false) |
||
81 | |||
82 | /** |
||
83 | * Get devices by page_id. |
||
84 | * |
||
85 | * @param int $page_id |
||
86 | * @param int $begin |
||
87 | * @param int $count |
||
88 | * |
||
89 | * @return \EasyWeChat\Support\Collection |
||
90 | */ |
||
91 | View Code Duplication | public function getDeviceByPageId($page_id, $begin, $count) |
|
102 | } |
||
103 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.