CustomerInfoRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A send() 0 28 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
use SlevomatCsobGateway\Validator;
9
10
class CustomerInfoRequest
11
{
12
13
	/** @var string */
14
	private $merchantId;
15
16
	/** @var string */
17
	private $customerId;
18
19 2
	public function __construct(
20
		string $merchantId,
21
		string $customerId
22
	)
23
	{
24 2
		Validator::checkCustomerId($customerId);
25
26 2
		$this->merchantId = $merchantId;
27 2
		$this->customerId = $customerId;
28 2
	}
29
30 1
	public function send(ApiClient $apiClient): CustomerInfoResponse
31
	{
32 1
		$response = $apiClient->get(
33 1
			'customer/echo/{merchantId}/{customerId}/{dttm}/{signature}',
34
			[
35 1
				'merchantId' => $this->merchantId,
36 1
				'customerId' => $this->customerId,
37
			],
38 1
			new SignatureDataFormatter([
39 1
				'merchantId' => null,
40
				'customerId' => null,
41
				'dttm' => null,
42
			]),
43 1
			new SignatureDataFormatter([
44 1
				'customerId' => null,
45
				'dttm' => null,
46
				'resultCode' => null,
47
				'resultMessage' => null,
48
			])
49
		);
50
51 1
		$data = $response->getData();
52
53 1
		return new CustomerInfoResponse(
54 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

54
			/** @scrutinizer ignore-type */ DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']),
Loading history...
55 1
			ResultCode::get($data['resultCode']),
56 1
			$data['resultMessage'],
57 1
			$data['customerId'] ?? null
58
		);
59
	}
60
61
}
62