Total Complexity | 51 |
Total Lines | 203 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Rabo often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Rabo, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
11 | class Rabo extends Engine |
||
12 | { |
||
13 | /** |
||
14 | * returns the name of the bank. |
||
15 | * |
||
16 | * @return string |
||
17 | */ |
||
18 | protected function parseStatementBank() |
||
19 | { |
||
20 | return 'Rabo'; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Overloaded: Rabo has different way of storing account info. |
||
25 | * |
||
26 | * @inheritdoc |
||
27 | */ |
||
28 | protected function parseTransactionAccount() |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Overloaded: Rabo has different way of storing account name. |
||
49 | * |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | protected function parseTransactionAccountName() |
||
53 | { |
||
54 | $results = []; |
||
55 | // SEPA MT940 Structured |
||
56 | if (preg_match('#/NAME/(.+?)\n?/(REMI|ADDR|ISDT|CSID)/#ms', $this->getCurrentTransactionData(), $results)) { |
||
57 | $accountName = trim($results[1]); |
||
58 | if (!empty($accountName)) { |
||
59 | return $this->sanitizeAccountName($accountName); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | if (preg_match('/^:61:.*? (.+)/m', $this->getCurrentTransactionData(), $results)) { |
||
64 | $accountName = trim($results[1]); |
||
65 | if (!empty($accountName)) { |
||
66 | return $this->sanitizeAccountName($accountName); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | if (preg_match('/(.*) Betaalautomaat/', $this->parseTransactionDescription(), $results)) { |
||
71 | $accountName = trim($results[1]); |
||
72 | if (!empty($accountName)) { |
||
73 | return $this->sanitizeAccountName($accountName); |
||
74 | } |
||
75 | } |
||
76 | return ''; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Overloaded: Rabo has different way of storing transaction value timestamps (ymd). |
||
81 | * |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | protected function parseTransactionEntryTimestamp() |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * Overloaded: Rabo has different way of storing transaction value timestamps (ymd). |
||
96 | * |
||
97 | * @inheritdoc |
||
98 | */ |
||
99 | protected function parseTransactionValueTimestamp() |
||
100 | { |
||
101 | $results = []; |
||
102 | if (preg_match('/^:61:([\d]{6})[C|D]/', $this->getCurrentTransactionData(), $results) && !empty($results[1])) { |
||
103 | return $this->sanitizeTimestamp($results[1], 'ymd'); |
||
104 | } |
||
105 | |||
106 | return 0; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Overloaded: Rabo uses longer strings for accountnumbers. |
||
111 | * |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | protected function sanitizeAccount($string) |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Overloaded: Rabo encapsulates the description with /REMI/ for SEPA. |
||
126 | * |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | protected function sanitizeDescription($string) |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Overloaded: Is applicable if first line has :940:. |
||
154 | * |
||
155 | * @inheritdoc |
||
156 | */ |
||
157 | public static function isApplicable($string) |
||
160 | } |
||
161 | |||
162 | protected function parseTransactionType() |
||
217 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths