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 | View Code Duplication | class HeaderRemovePlugin implements Plugin |
|
| 17 | { |
||
| 18 | private $headers = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param array $headers headers to remove from the request |
||
| 22 | */ |
||
| 23 | 3 | public function __construct(array $headers) |
|
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | 1 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
| 41 | } |
||
| 42 |
If you suppress an error, we recommend checking for the error condition explicitly: