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 |
||
| 7 | class Response extends BaseResponse |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param mixed $data The response data |
||
| 11 | * @param int $status The response status code |
||
| 12 | * @param array $headers An array of response headers |
||
| 13 | * @param bool $json If the data is already a JSON string |
||
| 14 | */ |
||
| 15 | View Code Duplication | public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false) |
|
| 25 | |||
| 26 | /** |
||
| 27 | * Sets the response content. |
||
| 28 | * |
||
| 29 | * We need to allow all sorts of content, not just the ones the regular Response setContent() allows |
||
| 30 | * |
||
| 31 | * @param mixed $content |
||
| 32 | * @return Response |
||
| 33 | * @api |
||
| 34 | */ |
||
| 35 | public function setContent($content) |
||
| 41 | } |
||
| 42 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.