Conditions | 12 |
Paths | 12 |
Total Lines | 54 |
Code Lines | 45 |
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 |
||
78 | private function parseContent($preparedArray) |
||
79 | { |
||
80 | $statement = []; |
||
81 | foreach ($preparedArray as $key => $accountBlock) { |
||
82 | foreach ($accountBlock as $tagLine) { |
||
83 | if (preg_match('/^:(.{2,3}):(.*)/s', $tagLine, $matches)) { |
||
84 | $tagNum = $matches[1]; |
||
85 | $tagContent = $matches[2]; |
||
86 | |||
87 | switch ($tagNum) { |
||
88 | case '20': |
||
89 | $generationDate = $this->parseStatementIdentifier($tagContent); |
||
90 | $statement[$key]['generationDate'] = $generationDate; |
||
91 | break; |
||
92 | case '25': |
||
93 | $accountNumber = $this->parseAccountNumber($tagContent); |
||
94 | $statement[$key]['accountNumber'] = $accountNumber; |
||
95 | break; |
||
96 | case '28C': |
||
97 | $statementNumber = $this->parseStatementNumber($tagContent); |
||
98 | $statement[$key]['statementNumber'] = $statementNumber; |
||
99 | break; |
||
100 | case '60F': |
||
101 | $openingBalance = $this->parseBalance($tagContent); |
||
102 | $statement[$key]['openingBalance'] = $openingBalance; |
||
103 | break; |
||
104 | case '62F': |
||
105 | $closingBalance = $this->parseBalance($tagContent); |
||
106 | $statement[$key]['closingBalance'] = $closingBalance; |
||
107 | break; |
||
108 | case '64': |
||
109 | $availableBalance = $this->parseBalance($tagContent); |
||
110 | $statement[$key]['availableBalance'] = $availableBalance; |
||
111 | break; |
||
112 | case '61': |
||
113 | $transaction = $this->parseTransaction($tagContent); |
||
114 | $statement[$key]['transactions'][] = $transaction; |
||
115 | break; |
||
116 | case '86': |
||
117 | $details = $this->parseTransactionDetails($tagContent); |
||
118 | $arrayKeys = array_keys($statement[$key]['transactions']); |
||
119 | $lastKey = end($arrayKeys); |
||
120 | $statement[$key]['transactions'][$lastKey]['details'] = $details; |
||
121 | break; |
||
122 | } |
||
123 | } |
||
124 | else { |
||
125 | throw new \Exception('Invalid format of tag line'); |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | |||
130 | return $statement; |
||
131 | } |
||
132 | |||
254 |