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

Account   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 24
ccs 7
cts 7
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 getBalance() 0 7 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 Account
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 getBalance(): array
27
    {
28 1
        $balanceUri = $this->config->get('airtel-money.account.balance_uri');
29
30 1
        $response = $this->http->request('GET', $balanceUri);
31
32 1
        return json_decode((string) $response->getBody(), true);
33
    }
34
}
35