Conditions | 2 |
Paths | 1 |
Total Lines | 54 |
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 |
||
62 | |||
63 | Blade::directive('paystackEmbeded', function ($expression) { |
||
64 | eval("\$params = [$expression];"); |
||
65 | |||
66 | $amount = $params[0]; |
||
67 | $callback = $params[1]; |
||
68 | $email = $params[2]; |
||
69 | $meta = isset($params[3]) ? $params[3] : '{}'; |
||
70 | |||
71 | $public_key = Config::get('paystack-lite.public_key'); |
||
72 | $cdn = Config::get('paystack-lite.paystack_inline_js'); |
||
73 | |||
74 | return <<<PAYSTACK |
||
75 | <div id="paystackEmbedContainer"></div> |
||
76 | <script src="$cdn"></script> |
||
77 | <script> |
||
78 | var options = { |
||
79 | key: "$public_key", |
||
80 | email: "$email", |
||
81 | amount: "$amount"+'00', |
||
82 | metadata: $meta, |
||
83 | container: 'paystackEmbedContainer', |
||
84 | callback: function(response){ |
||
85 | $callback(response); |
||
|
|||
86 | } |
||
87 | }; |
||
88 | |||
89 | var handler = PaystackPop.setup(options); |
||
90 | handler.openIframe(); |
||
91 | </script> |
||
92 | PAYSTACK; |
||
93 | }); |
||
94 | } |
||
95 | } |
||
96 |