| Conditions | 9 |
| Paths | 5 |
| Total Lines | 54 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 48 | public function getGenerator() |
||
| 49 | { |
||
| 50 | $this->cbLoader(); |
||
| 51 | |||
| 52 | $data['page_title'] = 'API Generator'; |
||
| 53 | $data['tables'] = CRUDBooster::listCbTables(); |
||
| 54 | |||
| 55 | return view('CbApiGen::api_generator', $data); |
||
| 56 | } |
||
| 57 | |||
| 58 | public function getEditApi($id) |
||
| 59 | { |
||
| 60 | $this->cbLoader(); |
||
| 61 | |||
| 62 | $row = $this->findRow($id)->first(); |
||
| 63 | |||
| 64 | $data['row'] = $row; |
||
| 65 | $data['parameters'] = json_encode(unserialize($row->parameters)); |
||
| 66 | $data['responses'] = json_encode(unserialize($row->responses)); |
||
| 67 | $data['page_title'] = 'API Generator'; |
||
| 68 | |||
| 69 | $data['tables'] = CRUDBooster::listCbTables(); |
||
| 70 | |||
| 71 | return view('CbApiGen::api_generator', $data); |
||
| 72 | } |
||
| 73 | |||
| 74 | public function postSaveApiCustom() |
||
| 75 | { |
||
| 76 | $this->cbLoader(); |
||
| 77 | $posts = request()->all(); |
||
| 78 | |||
| 79 | $_data = []; |
||
| 80 | |||
| 81 | $_data['nama'] = g('nama'); |
||
| 82 | $_data['tabel'] = $posts['tabel']; |
||
| 83 | $_data['aksi'] = $posts['aksi']; |
||
| 84 | $_data['permalink'] = g('permalink'); |
||
| 85 | $_data['method_type'] = g('method_type'); |
||
| 86 | |||
| 87 | $json = $this->json(); |
||
| 88 | |||
| 89 | $_data['parameters'] = serialize(array_filter($json)); |
||
| 90 | |||
| 91 | $_data['sql_where'] = g('sql_where'); |
||
| 92 | |||
| 93 | $json = $this->json2(); |
||
| 94 | $json = array_filter($json); |
||
| 95 | $_data['responses'] = serialize($json); |
||
| 96 | $_data['keterangan'] = g('keterangan'); |
||
| 97 | |||
| 98 | $this->saveToDB($_data); |
||
| 99 | |||
| 100 | return redirect(CRUDBooster::mainpath())->with(['message' => 'Yeay, your api has been saved successfully !', 'message_type' => 'success']); |
||
| 101 | } |
||
| 102 | |||
| 192 |