Conditions | 14 |
Paths | 14 |
Total Lines | 51 |
Code Lines | 26 |
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 |
||
20 | public function validateAppruve(array $response, IdFilter $IdFilter): array |
||
21 | { |
||
22 | $idType = $IdFilter->getIDType(); |
||
23 | |||
24 | if ($IdFilter->getCountry() == IdFilter::COUNTRIES['GHANA']) { |
||
25 | |||
26 | if ($idType == IdFilter::IDVALUES['TYPE_VOTER_CARD']) { |
||
27 | return $response; |
||
28 | } //Exclude Appruve Field Verification for this |
||
29 | |||
30 | if ($idType == IdFilter::IDVALUES['TYPE_TIN']) { |
||
31 | if (!$response['data']['is_valid']) { |
||
32 | throw new NotValidException('Tin is not valid'); |
||
33 | } |
||
34 | |||
35 | return $response; |
||
36 | } //Exclude Appruve Field Verification for this |
||
37 | |||
38 | if ($idType == IdFilter::IDVALUES['TYPE_DRIVERS_LICENSE']) { |
||
39 | if (!$response['data']['is_full_name_match']) { |
||
40 | throw new DataMismatchException('Fullname does not match'); |
||
41 | } |
||
42 | |||
43 | if (!$response['data']['is_date_of_birth_match']) { |
||
44 | throw new DataMismatchException('Date of birth does not match'); |
||
45 | } |
||
46 | return $response; |
||
47 | } //Exclude Appruve Field Verification for this |
||
48 | |||
49 | if ($idType == IdFilter::IDVALUES['TYPE_SSNIT']) { |
||
50 | if (!$response['data']['is_full_name_match']) { |
||
51 | throw new DataMismatchException('Fullname does not match'); |
||
52 | } |
||
53 | |||
54 | return $response; |
||
55 | } //Exclude Appruve Field Verification for this |
||
56 | |||
57 | } |
||
58 | |||
59 | if ( |
||
60 | $idType == IdFilter::IDVALUES['TYPE_TIN'] |
||
61 | || $idType == IdFilter::IDVALUES['TYPE_KRA'] |
||
62 | || $idType == IdFilter::IDVALUES['TELCO_SUBSCRIBER'] |
||
63 | ) { |
||
64 | return $response; |
||
65 | } //Exclude Appruve Field Verification for this |
||
66 | |||
67 | $isVerified = $this->verifyAppruve($response); |
||
68 | |||
69 | if ($isVerified == true) { |
||
70 | return $response; |
||
71 | } |
||
203 |