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 |
||
| 9 | class Request implements RequestInterface |
||
| 10 | { |
||
| 11 | use \GuzzleHttp\Psr7\MessageTrait { |
||
| 12 | withHeader as withParentHeader; |
||
| 13 | } |
||
| 14 | |||
| 15 | /** @var array Cached HTTP header collection with lowercase key to values */ |
||
| 16 | private $recipients = []; |
||
|
|
|||
| 17 | |||
| 18 | |||
| 19 | View Code Duplication | public function withAddedRecipient($email, $name = null) |
|
| 26 | |||
| 27 | View Code Duplication | public function withAddedRecipients(array $recipients) |
|
| 36 | |||
| 37 | View Code Duplication | public function withRecipient($email, $name = null) |
|
| 45 | |||
| 46 | View Code Duplication | public function withRecipients(array $recipients) { |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @throws \InvalidArgumentException |
||
| 58 | */ |
||
| 59 | protected function validateEmail($email) |
||
| 65 | |||
| 66 | } |
||
| 67 |
This check marks private properties in classes that are never used. Those properties can be removed.