HttpApi::postRequestInvoice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightning\Invoice\Infrastructure\Http;
6
7
use PhpLightning\Invoice\Domain\Http\HttpApiInterface;
8
use Symfony\Component\HttpClient\HttpClient;
9
10
final class HttpApi implements HttpApiInterface
11
{
12
    public function postRequestInvoice(string $uri, string $body, array $headers = []): ?array
13
    {
14
        $response = HttpClient::create()
15
            ->request('POST', $uri, [
16
                'headers' => $headers,
17
                'body' => $body,
18
            ]);
19
20
        return json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR);
21
    }
22
}
23