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 |
||
5 | class SFTP implements ConnectionInterface, ResourceTransferInterface |
||
6 | { |
||
7 | private $connection; // connection instance |
||
8 | |||
9 | private $sftp; // established sftp |
||
10 | |||
11 | |||
12 | public function __construct() |
||
15 | |||
16 | public function connect($host, $username, $password=NULL, string $pubkeyfile=NULL, string $privkeyfile=NULL) |
||
30 | |||
31 | public function connectWithKey($host, $username, string $pubkeyfile, string $privkeyfile, string $passphrase=NULL) |
||
41 | |||
42 | View Code Duplication | public function copy($remoteFile, $localFile) |
|
51 | |||
52 | View Code Duplication | public function send($localFile, $remoteFile) |
|
60 | |||
61 | public function getFilesList($dir) { |
||
71 | |||
72 | public function disconnect() |
||
77 | } |
||
78 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.