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); |
||
| 51 | class GSDownstreamService { |
||
| 52 | |||
| 53 | |||
| 54 | /** @var string */ |
||
| 55 | private $userId = ''; |
||
| 56 | |||
| 57 | /** @var IURLGenerator */ |
||
| 58 | private $urlGenerator; |
||
| 59 | |||
| 60 | /** @var GSEventsRequest */ |
||
| 61 | private $gsEventsRequest; |
||
| 62 | |||
| 63 | /** @var CirclesRequest */ |
||
| 64 | private $circlesRequest; |
||
| 65 | |||
| 66 | /** @var GlobalScaleService */ |
||
| 67 | private $globalScaleService; |
||
| 68 | |||
| 69 | /** @var ConfigService */ |
||
| 70 | private $configService; |
||
| 71 | |||
| 72 | /** @var MiscService */ |
||
| 73 | private $miscService; |
||
| 74 | |||
| 75 | |||
| 76 | /** |
||
| 77 | * GSUpstreamService constructor. |
||
| 78 | * |
||
| 79 | * @param $userId |
||
| 80 | * @param IURLGenerator $urlGenerator |
||
| 81 | * @param GSEventsRequest $gsEventsRequest |
||
| 82 | * @param CirclesRequest $circlesRequest |
||
| 83 | * @param GlobalScaleService $globalScaleService |
||
| 84 | * @param ConfigService $configService |
||
| 85 | * @param MiscService $miscService |
||
| 86 | */ |
||
| 87 | View Code Duplication | public function __construct( |
|
| 104 | |||
| 105 | |||
| 106 | /** |
||
| 107 | * @param GSEvent $event |
||
| 108 | * |
||
| 109 | * @throws GSKeyException |
||
| 110 | * @throws GSStatusException |
||
| 111 | * @throws GlobalScaleEventException |
||
| 112 | * @throws CircleDoesNotExistException |
||
| 113 | * @throws ConfigNoCircleAvailableException |
||
| 114 | * @throws GlobalScaleDSyncException |
||
| 115 | */ |
||
| 116 | public function requestedEvent(GSEvent $event) { |
||
| 125 | |||
| 126 | |||
| 127 | /** |
||
| 128 | * @param GSEvent $event |
||
| 129 | */ |
||
| 130 | public function onNewEvent(GSEvent $event) { |
||
| 139 | |||
| 140 | } |
||
| 141 | |||
| 142 |