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 |
||
16 | class HttpHelperFacade |
||
17 | { |
||
18 | /** |
||
19 | * @var Response |
||
20 | */ |
||
21 | protected $response; |
||
22 | /** |
||
23 | * @var HTTPClient |
||
24 | */ |
||
25 | protected $httpclient; |
||
26 | /** |
||
27 | * @var \Padosoft\HTTPClient\RequestHelper |
||
28 | */ |
||
29 | protected $requestHelper; |
||
30 | |||
31 | /** |
||
32 | * HttpHelper constructor. |
||
33 | * @param HTTPClient $httpclient |
||
34 | */ |
||
35 | public function __construct(\Padosoft\HTTPClient\HTTPClient $httpclient) |
||
41 | |||
42 | /** |
||
43 | * Send HTTP Request |
||
44 | * |
||
45 | * @param $method |
||
46 | * @param $uri |
||
47 | * @param array $getParams |
||
48 | * @param array $postParams |
||
49 | * @param string $user |
||
50 | * @param string $password |
||
51 | * @param array $jsonParams |
||
52 | * @param int $requesTimeout |
||
53 | * @param bool $SSLVerify |
||
54 | * @param array $customHeaders |
||
55 | * @param string $accept |
||
56 | * @param string $protocolVersion |
||
57 | * @return Response |
||
58 | */ |
||
59 | public static function sendSimpleRequest($method, $uri |
||
82 | |||
83 | /** |
||
84 | * @param $uri |
||
85 | * @param array $getParams |
||
86 | * @param array $postParams |
||
87 | * @return Response |
||
88 | */ |
||
89 | public static function sendGet($uri, array $getParams=[], array $postParams=[]) |
||
101 | |||
102 | /** |
||
103 | * @param $uri |
||
104 | * @param array $getParams |
||
105 | * @param array $postParams |
||
106 | * @param $user |
||
107 | * @param $password |
||
108 | * @return Response |
||
109 | */ |
||
110 | View Code Duplication | public static function sendGetWithAuth($uri, array $getParams=[], array $postParams=[], $user, $password) |
|
123 | |||
124 | /** |
||
125 | * @param $uri |
||
126 | * @param array $getParams |
||
127 | * @param array $postParams |
||
128 | * @return Response |
||
129 | */ |
||
130 | public static function sendPost($uri, array $getParams=[], array $postParams=[]) |
||
140 | |||
141 | /** |
||
142 | * @param $uri |
||
143 | * @param array $getParams |
||
144 | * @param array $postParams |
||
145 | * @param $user |
||
146 | * @param $password |
||
147 | * @return Response |
||
148 | */ |
||
149 | View Code Duplication | public static function sendPostWithAuth($uri, array $getParams=[], array $postParams=[], $user, $password) |
|
159 | |||
160 | /** |
||
161 | * @param $uri |
||
162 | * @param array $jsonParams |
||
163 | * @param $user |
||
164 | * @param $password |
||
165 | * @return Response |
||
166 | */ |
||
167 | public static function sendPostJsonWithAuth($uri, array $jsonParams=[], $user, $password) |
||
176 | |||
177 | |||
178 | } |
||
179 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.