Code Duplication    Length = 41-42 lines in 2 locations

src/controller/ApiManagerController.php 2 locations

@@ 288-328 (lines=41) @@
285
                    $this->send_apimanager($url_apimanager,$client,$host,$transition,$api->api_key);
286
                  }
287
                }
288
                if($requests == 'Request'){
289
                  $model = "ApiKeys";
290
                  $fromState = "propose";
291
                  $toState = $requests;
292
                  $workflow = $this->getWorkflow($model);
293
                  $statesFrom = $this->getState($fromState);
294
            	  $statesTo = $this->getState($toState);
295
            	  if($workflow->count() == 0){
296
                      $error = true;
297
                      $statusCode = 404;
298
                      $title = 'Error';
299
                      $type = 'error';
300
                      $message = 'Error Workflow not found';
301
                      $result = 'Not Found';
302
            	  }
303
                  elseif($statesTo->count() == 0 || $statesFrom->count() == 0){
304
                      $error = true;
305
                      $statusCode = 404;
306
                      $title = 'Error';
307
                      $type = 'error';
308
                      $message = 'Error State not active or State not found';
309
                      $result = 'Not Found';
310
            	  }
311
                  else{
312
              		  $this->saveHistory($api, $workflow->first(), $statesFrom->first(), $statesTo->first(), $user_id);
313
                      $error = false;
314
                      $statusCode = 200;
315
                      $title = 'Success';
316
                      $type = 'success';
317
                      $message = 'Data created successfully. Your request has already been send.';
318
                      $result = $request->all();
319
            	  }
320
                }
321
                else{
322
                  $error = true;
323
                  $statusCode = 404;
324
                  $title = 'Error';
325
                  $type = 'error';
326
                  $message = 'Value Request must be Request.';
327
                  $result = $request->all();
328
                }
329
      		}
330
          }
331
          else {
@@ 396-437 (lines=42) @@
393
                  }
394
          		}
395
              }
396
              elseif($requests == 'Document Submitted'){
397
                $model = "ApiKeys";
398
                $fromState = $workstateto;
399
                $toState = $requests;
400
                $workflow = $this->getWorkflow($model);
401
                $statesFrom = $this->getState($fromState);
402
                $statesTo = $this->getState($toState);
403
                if($workflow->count() == 0){
404
                    $error = true;
405
                    $statusCode = 404;
406
                    $title = 'Error';
407
                    $type = 'error';
408
                    $message = 'Error Workflow not found';
409
                    $result = 'Not Found';
410
                }
411
                elseif($statesTo->count() == 0 || $statesFrom->count() == 0){
412
                    $error = true;
413
                    $statusCode = 404;
414
                    $title = 'Error';
415
                    $type = 'error';
416
                    $message = 'Error State not active or State not found';
417
                    $result = 'Not Found';
418
                }
419
                else{
420
                  if($workstateto != 'Needs Completed Document'){
421
                    $error = true;
422
                    $statusCode = 404;
423
                    $title = 'Error';
424
                    $type = 'error';
425
                    $message = 'Data has already been taken.';
426
                    $result = $request->all();
427
                  }else {
428
                    $this->saveHistory($get, $workflow->first(), $statesFrom->first(), $statesTo->first(), $user_id);
429
                    $error = false;
430
                    $statusCode = 200;
431
                    $title = 'Success';
432
                    $type = 'success';
433
                    $message = 'Data created successfully. Your request has already been send.';
434
                    $result = $request->all();
435
                  }
436
                }
437
              }
438
              else {
439
                $error = true;
440
                $statusCode = 404;