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 | private static function paystackEmbededCheckout() |
||
63 | { |
||
64 | |||
65 | |||
66 | Blade::directive('paystackEmbeded', function ($expression) { |
||
67 | |||
68 | /** |
||
69 | * @param $expression contains 4 parameters |
||
70 | * @param $params[0] amount |
||
71 | * @param $params[1] callback |
||
72 | * @param $params[2] email |
||
73 | * @param $params[3] meta |
||
74 | * |
||
75 | */ |
||
76 | |||
77 | eval("\$params = [$expression];"); |
||
78 | |||
79 | $amount = "\'" . $params[0] . "\'"; |
||
|
|||
80 | $callback = $params[1]; |
||
81 | $email = $params[2]; |
||
82 | $email = "\'" . $email . "\'"; |
||
83 | $meta = isset($params[3]) ? $params[3] : '{}'; |
||
84 | |||
85 | $public_key = "\'" . Config::get('paystack-lite.public_key') . "\'"; |
||
86 | $paystack_js = '<script src="' . Config::get('paystack-lite.paystack_inline_js') . '"></script>'; |
||
87 | $script_open = "<script>"; |
||
88 | $script_closed = "</script>"; |
||
89 | |||
90 | return "<?php |
||
91 | |||
92 | echo ' $paystack_js |
||
93 | |||
94 | <div id=\"paystackEmbedContainer\"></div> |
||
95 | $script_open |
||
96 | |||
97 | var options = { |
||
98 | key: $public_key, |
||
99 | email: $email, |
||
100 | amount: $amount+\'00\', |
||
101 | metadata: $meta, |
||
102 | container: \'paystackEmbedContainer\', |
||
103 | callback: function(response){ |
||
104 | $callback(response); |
||
105 | } |
||
106 | }; |
||
107 | |||
108 | var handler = PaystackPop.setup(options); |
||
109 | handler.openIframe(); |
||
110 | |||
111 | $script_closed |
||
112 | '; |
||
113 | ?>"; |
||
114 | }); |
||
115 | } |
||
116 | } |
||
117 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.