Conditions | 2 |
Paths | 2 |
Total Lines | 65 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
55 | public function testBuildsBankAccount() |
||
56 | { |
||
57 | $Ofx = new Ofx($this->ofxData); |
||
58 | |||
59 | $bankAccount = $Ofx->bankAccount; |
||
60 | self::assertEquals('23382938', $bankAccount->transactionUid); |
||
61 | self::assertEquals('098-121', $bankAccount->accountNumber); |
||
62 | self::assertEquals('987654321', $bankAccount->routingNumber); |
||
63 | self::assertEquals('SAVINGS', $bankAccount->accountType); |
||
64 | self::assertEquals('5250.00', $bankAccount->balance); |
||
65 | self::assertInstanceOf('DateTime', $bankAccount->balanceDate); |
||
66 | |||
67 | $statement = $bankAccount->statement; |
||
68 | self::assertEquals('USD', $statement->currency); |
||
69 | self::assertInstanceOf('DateTime', $statement->startDate); |
||
70 | self::assertInstanceOf('DateTime', $statement->endDate); |
||
71 | |||
72 | $transactions = $statement->transactions; |
||
73 | self::assertCount(3, $transactions); |
||
74 | |||
75 | $expectedTransactions = [ |
||
76 | [ |
||
77 | 'type' => 'CREDIT', |
||
78 | 'typeDesc' => 'Generic credit', |
||
79 | 'amount' => '200.00', |
||
80 | 'uniqueId' => '980315001', |
||
81 | 'name' => 'DEPOSIT', |
||
82 | 'memo' => 'automatic deposit', |
||
83 | 'sic' => '', |
||
84 | 'checkNumber' => '' |
||
85 | ], |
||
86 | [ |
||
87 | 'type' => 'CREDIT', |
||
88 | 'typeDesc' => 'Generic credit', |
||
89 | 'amount' => '150.00', |
||
90 | 'uniqueId' => '980310001', |
||
91 | 'name' => 'TRANSFER', |
||
92 | 'memo' => 'Transfer from checking', |
||
93 | 'sic' => '', |
||
94 | 'checkNumber' => '' |
||
95 | ], |
||
96 | [ |
||
97 | 'type' => 'CHECK', |
||
98 | 'typeDesc' => 'Cheque', |
||
99 | 'amount' => '-100.00', |
||
100 | 'uniqueId' => '980309001', |
||
101 | 'name' => 'Cheque', |
||
102 | 'memo' => '', |
||
103 | 'sic' => '', |
||
104 | 'checkNumber' => '1025' |
||
105 | ], |
||
106 | |||
107 | ]; |
||
108 | |||
109 | foreach ($transactions as $i => $transaction) { |
||
110 | self::assertEquals($expectedTransactions[$i]['type'], $transaction->type); |
||
111 | self::assertEquals($expectedTransactions[$i]['typeDesc'], $transaction->typeDesc); |
||
112 | self::assertEquals($expectedTransactions[$i]['amount'], $transaction->amount); |
||
113 | self::assertEquals($expectedTransactions[$i]['uniqueId'], $transaction->uniqueId); |
||
114 | self::assertEquals($expectedTransactions[$i]['name'], $transaction->name); |
||
115 | self::assertEquals($expectedTransactions[$i]['memo'], $transaction->memo); |
||
116 | self::assertEquals($expectedTransactions[$i]['sic'], $transaction->sic); |
||
117 | self::assertEquals($expectedTransactions[$i]['checkNumber'], $transaction->checkNumber); |
||
118 | self::assertInstanceOf('DateTime', $transaction->date); |
||
119 | self::assertInstanceOf('DateTime', $transaction->userInitiatedDate); |
||
120 | } |
||
123 |