1 | <?php |
||||
2 | |||||
3 | namespace Bytesfield\SimpleKyc\Services; |
||||
4 | |||||
5 | use Noodlehaus\Config; |
||||
6 | use Mpociot\Pipeline\Pipeline; |
||||
7 | use Bytesfield\SimpleKyc\Pipes\Smile; |
||||
8 | use Bytesfield\SimpleKyc\Pipes\Appruve; |
||||
9 | use Bytesfield\SimpleKyc\Classes\IdFilter; |
||||
10 | use Bytesfield\SimpleKyc\Classes\Validation; |
||||
11 | use Bytesfield\SimpleKyc\Pipes\Credequity; |
||||
12 | |||||
13 | class IdVerification |
||||
14 | { |
||||
15 | |||||
16 | public function __construct($data) |
||||
17 | { |
||||
18 | $this->country = filterCountry($data->country); |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
19 | $this->id_type = strtoupper($data->id_type) ?? null; |
||||
0 ignored issues
–
show
|
|||||
20 | $this->id_number = $data->id ?? null; |
||||
0 ignored issues
–
show
|
|||||
21 | $this->first_name = $data->first_name ?? null; |
||||
0 ignored issues
–
show
|
|||||
22 | $this->last_name = $data->last_name ?? null; |
||||
0 ignored issues
–
show
|
|||||
23 | $this->middle_name = $data->middle_name ?? null; |
||||
0 ignored issues
–
show
|
|||||
24 | $this->date_of_birth = $data->date_of_birth ?? null; |
||||
0 ignored issues
–
show
|
|||||
25 | $this->phone = $data->phone_number ?? null; |
||||
0 ignored issues
–
show
|
|||||
26 | $this->pin = $data->pin ?? null; |
||||
0 ignored issues
–
show
|
|||||
27 | $this->tin = $data->tin ?? null; |
||||
0 ignored issues
–
show
|
|||||
28 | $this->gender = $data->gender ?? null; |
||||
0 ignored issues
–
show
|
|||||
29 | $this->full_name = $this->first_name . ' ' . $this->last_name; |
||||
0 ignored issues
–
show
|
|||||
30 | $this->user_id = $data->user_id ?? null; |
||||
0 ignored issues
–
show
|
|||||
31 | $this->company = $data->company ?? null; |
||||
0 ignored issues
–
show
|
|||||
32 | $this->registration_number = $data->registration_number ?? null; |
||||
0 ignored issues
–
show
|
|||||
33 | |||||
34 | $this->config = new Config(__DIR__ . '/../config'); |
||||
0 ignored issues
–
show
|
|||||
35 | |||||
36 | $this->appruveHandler = $this->config->get('appruve.handler'); |
||||
0 ignored issues
–
show
|
|||||
37 | $this->smileHandler = $this->config->get('smile.handler'); |
||||
0 ignored issues
–
show
|
|||||
38 | $this->credequityHandler = $this->config->get('credequity.handler'); |
||||
0 ignored issues
–
show
|
|||||
39 | } |
||||
40 | |||||
41 | public function verify() |
||||
42 | { |
||||
43 | $IdFilter = new IdFilter( |
||||
44 | $this->country, |
||||
45 | $this->id_type, |
||||
46 | $this->id_number, |
||||
47 | $this->first_name, |
||||
48 | $this->last_name, |
||||
49 | $this->middle_name, |
||||
50 | $this->date_of_birth, |
||||
51 | $this->phone, |
||||
52 | $this->pin, |
||||
53 | $this->tin, |
||||
54 | $this->gender, |
||||
55 | $this->full_name, |
||||
56 | $this->user_id, |
||||
57 | $this->company, |
||||
58 | $this->registration_number |
||||
59 | |||||
60 | ); |
||||
61 | |||||
62 | $response = null; |
||||
0 ignored issues
–
show
|
|||||
63 | $pipes = [Smile::class, Appruve::class, Credequity::class,]; |
||||
64 | |||||
65 | $response = (new Pipeline)->send($IdFilter) |
||||
66 | ->through($pipes) |
||||
67 | ->then(function ($result) { |
||||
68 | return $result; |
||||
69 | }); |
||||
70 | |||||
71 | $executedHandler = strtoupper($IdFilter->getHandler()); |
||||
72 | |||||
73 | $validation = new Validation(); |
||||
74 | |||||
75 | //Validate Appruve Handler result |
||||
76 | if ($executedHandler == strtoupper($this->appruveHandler)) { |
||||
0 ignored issues
–
show
It seems like
$this->appruveHandler can also be of type null ; however, parameter $string of strtoupper() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
77 | |||||
78 | return $validation->validateAppruve($response, $IdFilter); |
||||
79 | } |
||||
80 | |||||
81 | //Validate Smile Handler result |
||||
82 | if ($executedHandler == strtoupper($this->smileHandler)) { |
||||
83 | return $validation->validateSmile($response, $IdFilter); |
||||
0 ignored issues
–
show
The call to
Bytesfield\SimpleKyc\Cla...dation::validateSmile() has too many arguments starting with $IdFilter .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||
84 | } |
||||
85 | |||||
86 | //Validate Credequity Handler result |
||||
87 | if ($executedHandler == strtoupper($this->credequityHandler)) { |
||||
88 | return $validation->validateCredequity($response, $IdFilter); |
||||
89 | } |
||||
90 | |||||
91 | return $response; |
||||
92 | } |
||||
93 | } |
||||
94 |