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 |
||
| 25 | abstract class Cmd |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * Gets called by composer after a successful package installation. |
||
| 29 | * |
||
| 30 | * @param \Composer\Script\Event $event |
||
| 31 | * @param string $config |
||
| 32 | */ |
||
| 33 | 1 | View Code Duplication | public static function configure(Event $event, $config = '') |
| 44 | |||
| 45 | /** |
||
| 46 | * Installs the hooks to your local repository. |
||
| 47 | * |
||
| 48 | * @param \Composer\Script\Event $event |
||
| 49 | * @param string $config |
||
| 50 | */ |
||
| 51 | 1 | View Code Duplication | public static function install(Event $event, string $config = '') |
| 60 | |||
| 61 | /** |
||
| 62 | * Create a CaptainHook Composer application. |
||
| 63 | * |
||
| 64 | * @param \Composer\Script\Event $event |
||
| 65 | * @param string $config |
||
| 66 | * @return \SebastianFeldmann\CaptainHook\Composer\Application |
||
| 67 | */ |
||
| 68 | 2 | private static function createApplication(Event $event, string $config = '') : Application |
|
| 76 | } |
||
| 77 |