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 |
||
8 | class HttpsClient extends SecureClientSocket implements HttpStream |
||
9 | { |
||
10 | use HttpClientTrait; |
||
11 | |||
12 | /** |
||
13 | * Create a new https client |
||
14 | * |
||
15 | * @param Url $url |
||
16 | * The url for http request |
||
17 | * @param string $proto |
||
18 | * The protocol to use (default = HTTP/1.1) |
||
19 | * @param integer $timeout |
||
20 | * Optional timeout for request (default = 10 seconds) |
||
21 | */ |
||
22 | 11 | View Code Duplication | public function __construct(Url $url, $proto = 'HTTP/1.1', $timeout = 10) |
33 | |||
34 | /** |
||
35 | * |
||
36 | * {@inheritdoc} |
||
37 | * @see \Generics\Streams\HttpStream::request() |
||
38 | */ |
||
39 | 11 | public function request(string $requestType) |
|
43 | } |