EchoRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A send() 0 24 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Call;
4
5
use DateTimeImmutable;
6
use SlevomatCsobGateway\Api\ApiClient;
7
use SlevomatCsobGateway\Crypto\SignatureDataFormatter;
8
9
class EchoRequest
10
{
11
12
	/** @var string */
13
	private $merchantId;
14
15 2
	public function __construct(string $merchantId)
16
	{
17 2
		$this->merchantId = $merchantId;
18 2
	}
19
20 1
	public function send(ApiClient $apiClient): EchoResponse
21
	{
22 1
		$response = $apiClient->get(
23 1
			'echo/{merchantId}/{dttm}/{signature}',
24
			[
25 1
				'merchantId' => $this->merchantId,
26
			],
27 1
			new SignatureDataFormatter([
28 1
				'merchantId' => null,
29
				'dttm' => null,
30
			]),
31 1
			new SignatureDataFormatter([
32 1
				'dttm' => null,
33
				'resultCode' => null,
34
				'resultMessage' => null,
35
			])
36
		);
37
38 1
		$data = $response->getData();
39
40 1
		return new EchoResponse(
41 1
			DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']),
0 ignored issues
show
Bug introduced by
It seems like DateTimeImmutable::creat...YmdHis', $data['dttm']) can also be of type false; however, parameter $responseDateTime of SlevomatCsobGateway\Call...Response::__construct() does only seem to accept DateTimeImmutable, 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 ignore-type  annotation

41
			/** @scrutinizer ignore-type */ DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']),
Loading history...
42 1
			ResultCode::get($data['resultCode']),
43 1
			$data['resultMessage']
44
		);
45
	}
46
47
}
48