Conditions | 4 |
Paths | 1 |
Total Lines | 55 |
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 |
||
77 | private static function paystackEmbededCheckout() |
||
78 | { |
||
79 | |||
80 | |||
81 | Blade::directive('paystackEmbeded', function ($expression) { |
||
82 | |||
83 | /** |
||
84 | * @param $expression contains 4 parameters |
||
85 | * @param $params[0] amount |
||
86 | * @param $params[1] callback |
||
87 | * @param $params[2] email |
||
88 | * @param $params[3] meta |
||
89 | * |
||
90 | */ |
||
91 | |||
92 | eval("\$params = [$expression];"); |
||
93 | |||
94 | $amount = "\'" . $params[0] . "\'"; |
||
|
|||
95 | $callback = $params[1]; |
||
96 | $fallback_email = Config::get('paystack-lite.customer_fallback_email'); |
||
97 | $email = isset($params[2]) ? filter_var($params[2], FILTER_VALIDATE_EMAIL) ? $params[2] : $fallback_email : $fallback_email; |
||
98 | $email = "\'" . $email . "\'"; |
||
99 | $meta = isset($params[3]) ? $params[3] : '{}'; |
||
100 | |||
101 | $public_key = "\'" . Config::get('paystack-lite.public_key') . "\'"; |
||
102 | $paystack_js = '<script src="' . Config::get('paystack-lite.paystack_inline_js') . '"></script>'; |
||
103 | $script_open = "<script>"; |
||
104 | $script_closed = "</script>"; |
||
105 | |||
106 | return "<?php |
||
107 | |||
108 | echo ' $paystack_js |
||
109 | |||
110 | <div id=\"paystackEmbedContainer\"></div> |
||
111 | $script_open |
||
112 | |||
113 | var options = { |
||
114 | key: $public_key, |
||
115 | email: $email, |
||
116 | amount: $amount+\'00\', |
||
117 | metadata: $meta, |
||
118 | container: \'paystackEmbedContainer\', |
||
119 | callback: function(response){ |
||
120 | $callback(response); |
||
121 | } |
||
122 | }; |
||
123 | |||
124 | var handler = PaystackPop.setup(options); |
||
125 | handler.openIframe(); |
||
126 | |||
127 | $script_closed |
||
128 | '; |
||
129 | ?>"; |
||
130 | }); |
||
131 | } |
||
132 | } |
||
133 |
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.