Conditions | 8 |
Paths | 11 |
Total Lines | 65 |
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 |
||
69 | public function execute() |
||
70 | { |
||
71 | $result = $this->resultJsonFactory->create(); |
||
72 | |||
73 | $storeId = $this->storeManager->getStore()->getId(); |
||
74 | $authKey = $this->request->getParam('auth_key'); |
||
75 | $authSecret = $this->request->getParam('auth_secret'); |
||
76 | $wallets = $this->request->getParam('wallets'); |
||
77 | $testing = ('1' === $this->request->getParam('is_test')); |
||
78 | |||
79 | if (empty($authKey)) { |
||
80 | return $result->setData([ |
||
81 | 'success' => false, |
||
82 | 'message' => __('You need to fill Auth API Key') |
||
83 | ]); |
||
84 | } |
||
85 | |||
86 | if (empty($authSecret)) { |
||
87 | return $result->setData([ |
||
88 | 'success' => false, |
||
89 | 'message' => __('You need to fill Auth API Secret') |
||
90 | ]); |
||
91 | } |
||
92 | |||
93 | if (empty($wallets)) { |
||
94 | return $result->setData([ |
||
95 | 'success' => false, |
||
96 | 'message' => __('You need to fill Wallets') |
||
97 | ]); |
||
98 | } |
||
99 | |||
100 | if ($authSecret === $this::SECRET_MASK) { |
||
101 | $authSecret = null; |
||
102 | } |
||
103 | |||
104 | $b2binpay = $this->adapterFactory->create( |
||
105 | $storeId, |
||
106 | $authKey, |
||
107 | $authSecret, |
||
108 | $testing |
||
109 | ); |
||
110 | |||
111 | try { |
||
112 | $b2binpay->getAuthToken(); |
||
113 | } catch (B2BinpayException $e) { |
||
114 | return $result->setData([ |
||
115 | 'success' => false, |
||
116 | 'message' => __('Wrong Auth API Key/Secret') |
||
117 | ]); |
||
118 | } |
||
119 | |||
120 | foreach (explode('_', $wallets) as $wallet) { |
||
121 | try { |
||
122 | $b2binpay->getWallet($wallet); |
||
123 | } catch (B2BinpayException $e) { |
||
124 | return $result->setData([ |
||
125 | 'success' => false, |
||
126 | 'message' => __('Wrong Wallet ID: ' . $wallet) |
||
127 | ]); |
||
128 | } |
||
129 | } |
||
130 | |||
131 | return $result->setData([ |
||
132 | 'success' => true, |
||
133 | 'message' => __('Success') |
||
134 | ]); |
||
145 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths