Code Duplication    Length = 40-40 lines in 2 locations

src/controller/HostkeysController.php 2 locations

@@ 63-102 (lines=40) @@
60
   *
61
   * @return Response
62
   */
63
  public function store(Request $request)
64
  {
65
      try {
66
          if($request->keys != NULL){
67
            $keys = $request->keys;
68
          }else {
69
            $keys = "";
70
          }
71
          $hostkey = New Hostkeys;
72
          $hostkey->hostname 	= str_replace(array('https://', 'http://'), array('',''),$request->hostname);
73
          $hostkey->keys 		= $keys;
74
          $hostkey->state 		= $request->state;
75
          $hostkey->transition 	= $request->transition;
76
          $hostkey->user_id     = $request->user_id;
77
          $hostkey->save();
78
79
          $error = false;
80
          $statusCode = 200;
81
          $title = 'Success';
82
          $type = 'success';
83
          $message = 'Data Saved Successfuly.';
84
          $result = $hostkey;
85
      } catch (Exception $e) {
86
          $error = true;
87
          $statusCode = 404;
88
          $title = 'Error';
89
          $type = 'error';
90
          $message = 'Error';
91
          $result = 'Not Found';
92
      } finally {
93
          return Response::json(array(
94
            'error' => $error,
95
            'status' => $statusCode,
96
            'title' => $title,
97
            'type' => $type,
98
            'message' => $message,
99
            'result' => $result
100
          ));
101
      }
102
  }
103
104
  /**
105
   * Display the specified resource.
@@ 309-348 (lines=40) @@
306
   * @param  int  $id
307
   * @return Response
308
   */
309
   public function update(Request $request, $id)
310
   {
311
       try {
312
           if($request->keys != NULL){
313
             $keys = $request->keys;
314
           }else {
315
             $keys = "";
316
           }
317
           $hostkey = Hostkeys::findOrFail($id);
318
           $hostkey->hostname 	= str_replace(array('https://', 'http://'), array('',''),$request->hostname);
319
           $hostkey->keys 		= $keys;
320
           $hostkey->state 		= $request->state;
321
           $hostkey->transition = $request->transition;
322
           $hostkey->user_id    = $request->user_id;
323
           $hostkey->save();
324
325
           $error = false;
326
           $statusCode = 200;
327
           $title = 'Success';
328
           $type = 'success';
329
           $message = 'Data Saved Successfuly.';
330
           $result = $hostkey;
331
       } catch (Exception $e) {
332
           $error = true;
333
           $statusCode = 404;
334
           $title = 'Error';
335
           $type = 'error';
336
           $message = 'Error';
337
           $result = 'Not Found';
338
       } finally {
339
           return Response::json(array(
340
             'error' => $error,
341
             'status' => $statusCode,
342
             'title' => $title,
343
             'type' => $type,
344
             'message' => $message,
345
             'result' => $result
346
           ));
347
       }
348
   }
349
350
  /**
351
   * Remove the specified resource from storage.