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 declare(strict_types=1); |
||
| 48 | class GSDownstreamService { |
||
| 49 | |||
| 50 | |||
| 51 | /** @var string */ |
||
| 52 | private $userId = ''; |
||
| 53 | |||
| 54 | /** @var IURLGenerator */ |
||
| 55 | private $urlGenerator; |
||
| 56 | |||
| 57 | /** @var GSEventsRequest */ |
||
| 58 | private $gsEventsRequest; |
||
| 59 | |||
| 60 | /** @var CirclesRequest */ |
||
| 61 | private $circlesRequest; |
||
| 62 | |||
| 63 | /** @var GlobalScaleService */ |
||
| 64 | private $globalScaleService; |
||
| 65 | |||
| 66 | /** @var ConfigService */ |
||
| 67 | private $configService; |
||
| 68 | |||
| 69 | /** @var MiscService */ |
||
| 70 | private $miscService; |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * GSUpstreamService constructor. |
||
| 75 | * |
||
| 76 | * @param $userId |
||
| 77 | * @param IURLGenerator $urlGenerator |
||
| 78 | * @param GSEventsRequest $gsEventsRequest |
||
| 79 | * @param CirclesRequest $circlesRequest |
||
| 80 | * @param GlobalScaleService $globalScaleService |
||
| 81 | * @param ConfigService $configService |
||
| 82 | * @param MiscService $miscService |
||
| 83 | */ |
||
| 84 | View Code Duplication | public function __construct( |
|
| 101 | |||
| 102 | |||
| 103 | /** |
||
| 104 | * @param GSEvent $event |
||
| 105 | * |
||
| 106 | * @throws GlobalScaleEventException |
||
| 107 | * @throws GSKeyException |
||
| 108 | * @throws GSStatusException |
||
| 109 | */ |
||
| 110 | public function requestedEvent(GSEvent $event) { |
||
| 119 | |||
| 120 | |||
| 121 | /** |
||
| 122 | * @param GSEvent $event |
||
| 123 | */ |
||
| 124 | public function onNewEvent(GSEvent $event) { |
||
| 133 | |||
| 134 | } |
||
| 135 | |||
| 136 |