Passed
Push — main ( 5dbf08...9589c4 )
by Brian
02:38
created

Kyc   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUser() 0 11 1
1
<?php
2
3
namespace Bmatovu\AirtelMoney\Products;
4
5
use GuzzleHttp\ClientInterface;
6
use Illuminate\Container\Container;
7
use Illuminate\Contracts\Config\Repository;
8
9
class Kyc
10
{
11
    protected ClientInterface $http;
12
13
    protected Repository $config;
14
15 1
    public function __construct(ClientInterface $http)
16
    {
17 1
        $this->http = $http;
18 1
        $this->config = Container::getInstance()->make('config');
19
    }
20
21
    /**
22
     * @return array<string, mixed>
23
     *
24
     * @throws \GuzzleHttp\Exception\TransferException
25
     */
26 1
    public function getUser(string $phoneNumber): array
27
    {
28 1
        $phoneNumber = substr($phoneNumber, -9);
29
30 1
        $userUri = $this->config->get('airtel-money.kyc.user_uri');
31
32 1
        $userUri = str_replace(':phoneNumber', $phoneNumber, $userUri);
33
34 1
        $response = $this->http->request('GET', $userUri);
35
36 1
        return json_decode((string) $response->getBody(), true);
37
    }
38
}
39