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 |
||
| 18 | class HttpsClient extends SecureClientSocket implements HttpStream |
||
| 19 | { |
||
| 20 | use HttpClientTrait; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Create a new https client |
||
| 24 | * |
||
| 25 | * @param Url $url |
||
| 26 | * The url for http request |
||
| 27 | * @param string $proto |
||
| 28 | * The protocol to use (default = HTTP/1.1) |
||
| 29 | * @param integer $timeout |
||
| 30 | * Optional timeout for request (default = 10 seconds) |
||
| 31 | */ |
||
| 32 | 12 | View Code Duplication | public function __construct(Url $url, $proto = 'HTTP/1.1', $timeout = 10) |
| 43 | |||
| 44 | /** |
||
| 45 | * |
||
| 46 | * {@inheritdoc} |
||
| 47 | * @see \Generics\Streams\HttpStream::request() |
||
| 48 | */ |
||
| 49 | 11 | public function request(string $requestType) |
|
| 53 | } |
||
| 54 |