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 |
||
15 | class HeaderServiceActivator extends \PEIP\Service\ServiceActivator |
||
16 | { |
||
17 | protected $headerName; |
||
18 | |||
19 | /** |
||
20 | * @param $serviceCallable |
||
21 | * @param $inputChannel |
||
22 | * @param $outputChannel |
||
23 | * |
||
24 | * @return |
||
25 | */ |
||
26 | public function __construct($serviceCallable, $headerName, \PEIP\INF\Channel\Channel $inputChannel = null, \PEIP\INF\Channel\Channel $outputChannel = null) |
||
31 | |||
32 | /** |
||
33 | * Calls a method on a service (registered as a callable) with |
||
34 | * content/payload of given message as argument. |
||
35 | * |
||
36 | * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
||
37 | * |
||
38 | * @return mixed result of calling the registered service callable with message content/payload |
||
39 | */ |
||
40 | View Code Duplication | protected function callService(\PEIP\INF\Message\Message $message) |
|
53 | } |
||
54 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.