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 |
||
| 19 | class WebhookController extends Controller |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * $payum. |
||
| 23 | * |
||
| 24 | * @var \Payum\Core\Payum |
||
| 25 | */ |
||
| 26 | protected $payum; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * $responseFactory. |
||
| 30 | * |
||
| 31 | * @var \Illuminate\Contracts\Routing\ResponseFactory |
||
| 32 | */ |
||
| 33 | protected $responseFactory; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * $replyToSymfonyResponseConverter. |
||
| 37 | * |
||
| 38 | * @var \Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter |
||
| 39 | */ |
||
| 40 | protected $replyToSymfonyResponseConverter; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * __construct. |
||
| 44 | * |
||
| 45 | * @param \Payum\Core\Payum $payum |
||
| 46 | * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory |
||
| 47 | * @param \Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter $replyToSymfonyResponseConverter |
||
| 48 | */ |
||
| 49 | 10 | public function __construct( |
|
| 58 | |||
| 59 | /** |
||
| 60 | * handleAuthorize. |
||
| 61 | * |
||
| 62 | * @param \Illuminate\Http\Request $request |
||
| 63 | * @param string $payumToken |
||
| 64 | * @return \Illuminate\Http\Response |
||
| 65 | */ |
||
| 66 | 1 | public function handleAuthorize(Request $request, $payumToken) |
|
| 75 | |||
| 76 | /** |
||
| 77 | * handleCancel. |
||
| 78 | * |
||
| 79 | * @param \Illuminate\Http\Request $request |
||
| 80 | * @param string $payumToken |
||
| 81 | * @return \Illuminate\Http\Response |
||
| 82 | */ |
||
| 83 | 1 | View Code Duplication | public function handleCancel(Request $request, $payumToken) |
| 96 | |||
| 97 | /** |
||
| 98 | * handleCapture. |
||
| 99 | * |
||
| 100 | * @param \Illuminate\Http\Request $request |
||
| 101 | * @param string $payumToken |
||
| 102 | * @return \Illuminate\Http\Response |
||
| 103 | */ |
||
| 104 | 2 | public function handleCapture(Request $request, $payumToken = null) |
|
| 113 | |||
| 114 | /** |
||
| 115 | * handleNotify. |
||
| 116 | * |
||
| 117 | * @param \Illuminate\Http\Request $request |
||
| 118 | * @param string $payumToken |
||
| 119 | * @return \Illuminate\Http\Response |
||
| 120 | */ |
||
| 121 | 1 | public function handleNotify(Request $request, $payumToken) |
|
| 129 | |||
| 130 | /** |
||
| 131 | * handleNotifyUnsafe. |
||
| 132 | * |
||
| 133 | * @param string $gatewayName |
||
| 134 | * @return \Illuminate\Http\Response |
||
| 135 | */ |
||
| 136 | 2 | public function handleNotifyUnsafe($gatewayName) |
|
| 147 | |||
| 148 | /** |
||
| 149 | * handleRefund. |
||
| 150 | * |
||
| 151 | * @param \Illuminate\Http\Request $request |
||
| 152 | * @param string $payumToken |
||
| 153 | * @return \Illuminate\Http\Response |
||
| 154 | */ |
||
| 155 | 1 | View Code Duplication | public function handleRefund(Request $request, $payumToken) |
| 169 | |||
| 170 | /** |
||
| 171 | * handlePayout. |
||
| 172 | * |
||
| 173 | * @param \Illuminate\Http\Request $request |
||
| 174 | * @param string $payumToken |
||
| 175 | * @return \Illuminate\Http\Response |
||
| 176 | */ |
||
| 177 | 1 | public function handlePayout(Request $request, $payumToken) |
|
| 186 | |||
| 187 | /** |
||
| 188 | * handleSync. |
||
| 189 | * |
||
| 190 | * @param \Illuminate\Http\Request $request |
||
| 191 | * @param string $payumToken |
||
| 192 | * @return \Illuminate\Http\Response |
||
| 193 | */ |
||
| 194 | public function handleSync(Request $request, $payumToken) |
||
| 203 | |||
| 204 | /** |
||
| 205 | * handleReceived. |
||
| 206 | * |
||
| 207 | * @param \Illuminate\Http\Request $request |
||
| 208 | * @param string $payumToken |
||
| 209 | * @param callable $callback |
||
| 210 | * @return \Illuminate\Http\Response |
||
| 211 | */ |
||
| 212 | 8 | protected function handleReceived(Request $request, $payumToken, callable $callback) |
|
| 231 | |||
| 232 | 10 | protected function getPayum() |
|
| 236 | |||
| 237 | 2 | protected function convertReply($reply) |
|
| 241 | } |
||
| 242 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.