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 | final class AsyncClient implements AsyncClientInterface |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var FoundationClientInterface |
||
| 22 | */ |
||
| 23 | private $client; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Create a new AsyncClient based on the loop and other options pass |
||
| 27 | * |
||
| 28 | * @param LoopInterface $loop |
||
| 29 | * @param string $baseUrl |
||
| 30 | * @param string $username |
||
| 31 | * @param string $password |
||
| 32 | * @param array $options |
||
| 33 | * @return AsyncClient |
||
| 34 | */ |
||
| 35 | public static function create( |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Create an AsyncClient from a ApiClients\Foundation\ClientInterface. |
||
| 49 | * Be sure to pass in a client with the options from ApiSettings and the Async namespace suffix. |
||
| 50 | * |
||
| 51 | * @param FoundationClientInterface $client |
||
| 52 | * @return AsyncClient |
||
| 53 | */ |
||
| 54 | public static function createFromClient(FoundationClientInterface $client): self |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param FoundationClientInterface $client |
||
| 61 | */ |
||
| 62 | private function __construct(FoundationClientInterface $client) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return PromiseInterface |
||
| 69 | */ |
||
| 70 | public function overview(): PromiseInterface |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return ObservableInterface |
||
| 83 | */ |
||
| 84 | View Code Duplication | public function queues(): ObservableInterface |
|
| 96 | |||
| 97 | /** |
||
| 98 | * @return ObservableInterface |
||
| 99 | */ |
||
| 100 | View Code Duplication | public function connections(): ObservableInterface |
|
| 112 | } |
||
| 113 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.