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 |
||
22 | class ChannelCommand extends AbstractCommand |
||
23 | { |
||
24 | /** |
||
25 | * AbstractCommand constructor. |
||
26 | * |
||
27 | * @param Payload $payload |
||
28 | * @param RealTimeClient $client |
||
29 | * @param array|null $configuration |
||
30 | */ |
||
31 | 2 | View Code Duplication | public function __construct(Payload $payload, RealTimeClient $client, array $configuration = null) |
39 | |||
40 | /** |
||
41 | * @return bool|string |
||
42 | * |
||
43 | * @throws \Doctrine\DBAL\DBALException |
||
44 | */ |
||
45 | 1 | public function process() |
|
49 | |||
50 | /** |
||
51 | * @param array $data |
||
52 | * @example $data: |
||
53 | * [ |
||
54 | * "type": "channel_created", |
||
55 | * "channel": { |
||
56 | * "id": "C024BE91L", |
||
57 | * "name": "fun", |
||
58 | * "created": 1360782804, |
||
59 | * "creator": "U024BE7LH" |
||
60 | * } |
||
61 | * ] |
||
62 | */ |
||
63 | 1 | public function processChannelCreated(array $data) |
|
75 | } |
||
76 |