Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
37 | public function test_values( $message ) { |
||
38 | $expected = new XML\StatusResponseMessage(); |
||
39 | |||
40 | $expected->result = 'ok'; |
||
41 | |||
42 | // E-wallet |
||
43 | $ewallet = new stdClass(); |
||
44 | |||
45 | $ewallet->id = '12345'; |
||
46 | $ewallet->status = 'completed'; |
||
47 | $ewallet->created = '20070723171623'; |
||
48 | $ewallet->modified = '20070903155907'; |
||
49 | $ewallet->reason_code = null; |
||
50 | $ewallet->reason = null; |
||
51 | |||
52 | $expected->ewallet = $ewallet; |
||
53 | |||
54 | // Customer |
||
55 | $customer = new stdClass(); |
||
56 | |||
57 | $customer->currency = 'EUR'; |
||
58 | $customer->amount = '1000'; |
||
59 | $customer->exchange_rate = '1'; |
||
60 | $customer->first_name = 'First'; |
||
61 | $customer->last_name = 'Last'; |
||
62 | $customer->city = 'City'; |
||
63 | $customer->state = null; |
||
64 | $customer->country = 'NL'; |
||
65 | |||
66 | $expected->customer = $customer; |
||
67 | |||
68 | // Transaction |
||
69 | $transaction = new stdClass(); |
||
70 | |||
71 | $transaction->id = 'ABCD1234'; |
||
72 | $transaction->currency = 'EUR'; |
||
73 | $transaction->amount = '1000'; |
||
74 | $transaction->description = 'My Description'; |
||
75 | $transaction->var1 = null; |
||
76 | $transaction->var2 = null; |
||
77 | $transaction->var3 = null; |
||
78 | $transaction->items = 'My Items'; |
||
79 | |||
80 | $expected->transaction = $transaction; |
||
81 | |||
82 | // Payment Details |
||
83 | $payment_details = new stdClass(); |
||
84 | |||
85 | $payment_details->type = 'IDEAL'; |
||
86 | $payment_details->account_iban = null; |
||
87 | $payment_details->account_bic = null; |
||
88 | $payment_details->account_id = null; |
||
89 | $payment_details->account_holder_name = null; |
||
90 | $payment_details->external_transaction_id = null; |
||
91 | |||
92 | $expected->payment_details = $payment_details; |
||
93 | |||
94 | $this->assertEquals( $expected, $message ); |
||
95 | } |
||
97 |