Conditions | 10 |
Paths | 12 |
Total Lines | 73 |
Code Lines | 41 |
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 |
||
45 | public function handle(IdFilter $IdFilter, Closure $next) |
||
46 | { |
||
47 | |||
48 | if (!$IdFilter->isSuccessful()) { |
||
49 | |||
50 | if ($IdFilter->getCountry() == IdFilter::COUNTRIES['NIGERIA']) { |
||
51 | |||
52 | if ($IdFilter->isWithImage()) { |
||
53 | return $this->getWithImage($IdFilter); |
||
54 | } |
||
55 | |||
56 | $idNumber = $IdFilter->getIDNumber(); |
||
57 | $firstName = $IdFilter->getFirstName(); |
||
58 | $lastName = $IdFilter->getLastName(); |
||
59 | $phone = $IdFilter->getPhoneNumber(); |
||
60 | |||
61 | if ($IdFilter->getIDType() === IdFilter::IDVALUES['TYPE_BVN']) { |
||
62 | $url = '/CredBvn/api/v1/Bvn/GetCustomerBvn'; |
||
63 | |||
64 | $body = [ |
||
65 | 'bvn' => $idNumber, |
||
66 | 'PhoneNumber' => $phone |
||
67 | ]; |
||
68 | |||
69 | return $this->postData($IdFilter, $body, $url); |
||
70 | } |
||
71 | if ($IdFilter->getIDType() === IdFilter::IDVALUES['TYPE_NIN']) { |
||
72 | if (!$IdFilter->isSuccessful()) { |
||
73 | $url = '/CredNin/api/v1/Identity?phoneNo=' . $phone; |
||
74 | $body = []; |
||
75 | |||
76 | return $this->postData($IdFilter, $body, $url); |
||
77 | } |
||
78 | |||
79 | //If request is not successful makes post with IdNumber |
||
80 | if (!$IdFilter->isSuccessful()) { |
||
81 | $url = '/CredNin/api/v1/IdentityByNin?nin=' . $idNumber; |
||
82 | $body = []; |
||
83 | |||
84 | return $this->postData($IdFilter, $body, $url); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | if ($IdFilter->getIDType() === IdFilter::IDVALUES['TYPE_DRIVERS_LICENSE']) { |
||
89 | $url = '/Verify/api/v1/FrscInfo'; |
||
90 | |||
91 | $body = [ |
||
92 | 'firstname' => $firstName, |
||
93 | 'lastname' => $lastName, |
||
94 | 'phoneNo' => $phone, |
||
95 | 'frscidentityNo' => $idNumber |
||
96 | ]; |
||
97 | |||
98 | return $this->postData($IdFilter, $body, $url); |
||
99 | } |
||
100 | |||
101 | if ($IdFilter->getIDType() === IdFilter::IDVALUES['TYPE_CUSTOMER_PROFILE']) { |
||
102 | $url = '/CredBvn/api/v1/CustomerProfile'; |
||
103 | //$IdFilter->setCredequityProfile(); |
||
104 | $profile = $IdFilter->getCredequityProfile(); |
||
105 | |||
106 | $body = [ |
||
107 | "Nin" => $profile['nin'], |
||
108 | "FrscNo" => $profile['frscno'], |
||
109 | "phoneNo" => $phone, |
||
110 | "Bvn" => $profile['bvn'] |
||
111 | ]; |
||
112 | |||
113 | return $this->postData($IdFilter, $body, $url); |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | return $next($IdFilter); |
||
118 | } |
||
178 |