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

Kyc::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
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