Conditions | 14 |
Paths | 66 |
Total Lines | 79 |
Code Lines | 41 |
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 |
||
29 | public function handle(Request $request) |
||
30 | { |
||
31 | $debugData = ['url' => $request->fullUrl(), 'data' => $request->all(), 'method' => $request->method()]; |
||
32 | |||
33 | Log::debug('Service Request', $debugData); |
||
34 | |||
35 | $data = $request->all(); |
||
36 | |||
37 | $postData = null; |
||
38 | |||
39 | if (isset($data['MMEX_Post'])) { |
||
40 | $postData = json_decode($data['MMEX_Post']); |
||
41 | } elseif (isset($data['postData'])) { |
||
42 | $postData = json_decode($data['postData']); |
||
43 | } |
||
44 | |||
45 | if ($postData) { |
||
46 | Log::debug('MmexController, $postData', [$postData]); |
||
47 | } |
||
48 | |||
49 | $function = $this->getFunction($data); |
||
50 | |||
51 | if ($function == MmexFunctions::CheckGuid) { |
||
52 | return $this->returnSuccess(); |
||
53 | } |
||
54 | |||
55 | if ($function == MmexFunctions::CheckApiVersion) { |
||
56 | return $this->returnText(Constants::$api_version); |
||
57 | } |
||
58 | |||
59 | if ($function == MmexFunctions::DownloadTransactions) { |
||
60 | return $this->returnText($this->mmexService->getTransactions()); |
||
61 | } |
||
62 | |||
63 | if ($function == MmexFunctions::DeleteBankAccounts) { |
||
64 | $this->mmexService->deleteAccounts(); |
||
65 | |||
66 | return $this->returnSuccess(); |
||
67 | } |
||
68 | |||
69 | if ($function == MmexFunctions::ImportBankAccounts) { |
||
70 | $this->mmexService->importBankAccounts($postData); |
||
71 | |||
72 | return $this->returnSuccess(); |
||
73 | } |
||
74 | |||
75 | if ($function == MmexFunctions::DeletePayees) { |
||
76 | $this->mmexService->deletePayees(); |
||
77 | |||
78 | return $this->returnSuccess(); |
||
79 | } |
||
80 | |||
81 | if ($function == MmexFunctions::ImportPayees) { |
||
82 | $this->mmexService->importPayees($postData); |
||
83 | |||
84 | return $this->returnSuccess(); |
||
85 | } |
||
86 | |||
87 | if ($function == MmexFunctions::DeleteCategories) { |
||
88 | $this->mmexService->deleteCategories(); |
||
89 | |||
90 | return $this->returnSuccess(); |
||
91 | } |
||
92 | |||
93 | if ($function == MmexFunctions::ImportCategories) { |
||
94 | $this->mmexService->importCategories($postData); |
||
95 | |||
96 | return $this->returnSuccess(); |
||
97 | } |
||
98 | |||
99 | if ($function == MmexFunctions::DeleteTransactions) { |
||
100 | $transactionId = $data["delete_group"]; |
||
101 | $this->mmexService->deleteTransactions($transactionId); |
||
102 | |||
103 | return $this->returnSuccess(); |
||
104 | } |
||
105 | |||
106 | return $data; |
||
107 | } |
||
108 | |||
168 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.