Code Duplication    Length = 41-43 lines in 2 locations

src/controller/ApiManagerController.php 2 locations

@@ 289-329 (lines=41) @@
286
                    $this->send_apimanager($url_apimanager,$client,$host,$transition);
287
                  }
288
                }
289
                if($requests == 'Request'){
290
                  $model = "ApiKeys";
291
                  $fromState = "propose";
292
                  $toState = $requests;
293
                  $workflow = $this->getWorkflow($model);
294
                  $statesFrom = $this->getState($fromState);
295
            			$statesTo = $this->getState($toState);
296
            			if($workflow->count() == 0){
297
                      $error = true;
298
                      $statusCode = 404;
299
                      $title = 'Error';
300
                      $type = 'error';
301
                      $message = 'Error Workflow not found';
302
                      $result = 'Not Found';
303
            			}
304
                  elseif($statesTo->count() == 0 || $statesFrom->count() == 0){
305
                      $error = true;
306
                      $statusCode = 404;
307
                      $title = 'Error';
308
                      $type = 'error';
309
                      $message = 'Error State not active or State not found';
310
                      $result = 'Not Found';
311
            			}
312
                  else{
313
              				$this->saveHistory($api, $workflow->first(), $statesFrom->first(), $statesTo->first(), $user_id);
314
                      $error = false;
315
                      $statusCode = 200;
316
                      $title = 'Success';
317
                      $type = 'success';
318
                      $message = 'Data created successfully. Your request has already been send.';
319
                      $result = $request->all();
320
            			}
321
                }
322
                else{
323
                  $error = true;
324
                  $statusCode = 404;
325
                  $title = 'Error';
326
                  $type = 'error';
327
                  $message = 'Value Request must be Request.';
328
                  $result = $request->all();
329
                }
330
      			}
331
          }
332
          else {
@@ 362-404 (lines=43) @@
359
              $message = 'Data has already been Rejected.';
360
              $result = $request->all();
361
            }
362
            else {
363
              if($requests == 'Request'){
364
                $model = "ApiKeys";
365
                $fromState = "propose";
366
                $toState = $requests;
367
                $workflow = $this->getWorkflow($model);
368
                $statesFrom = $this->getState($fromState);
369
          			$statesTo = $this->getState($toState);
370
          			if($workflow->count() == 0){
371
                    $error = true;
372
                    $statusCode = 404;
373
                    $title = 'Error';
374
                    $type = 'error';
375
                    $message = 'Error Workflow not found';
376
                    $result = 'Not Found';
377
          			}
378
                elseif($statesTo->count() == 0 || $statesFrom->count() == 0){
379
                    $error = true;
380
                    $statusCode = 404;
381
                    $title = 'Error';
382
                    $type = 'error';
383
                    $message = 'Error State not active or State not found';
384
                    $result = 'Not Found';
385
          			}
386
                else{
387
            				$this->saveHistory($get, $workflow->first(), $statesFrom->first(), $statesTo->first(), $user_id);
388
                    $error = false;
389
                    $statusCode = 200;
390
                    $title = 'Success';
391
                    $type = 'success';
392
                    $message = 'Data created successfully. Your request has already been send.';
393
                    $result = $request->all();
394
          			}
395
              }
396
              else {
397
                $error = true;
398
                $statusCode = 404;
399
                $title = 'Error';
400
                $type = 'error';
401
                $message = 'Value Request must be Request.';
402
                $result = $request->all();
403
              }
404
            }
405
          }
406
      } catch (Exception $e) {
407
          $error = true;