Issues (27)

src/Call/PostEchoRequest.php (1 issue)

Labels
Severity
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 PostEchoRequest
10
{
11
12
	/** @var string */
13
	private $merchantId;
14
15 2
	public function __construct(
16
		string $merchantId
17
	)
18
	{
19 2
		$this->merchantId = $merchantId;
20 2
	}
21
22 1
	public function send(ApiClient $apiClient): EchoResponse
23
	{
24 1
		$response = $apiClient->post(
25 1
			'echo',
26
			[
27 1
				'merchantId' => $this->merchantId,
28
			],
29 1
			new SignatureDataFormatter([
30 1
				'merchantId' => null,
31
				'dttm' => null,
32
			]),
33 1
			new SignatureDataFormatter([
34 1
				'dttm' => null,
35
				'resultCode' => null,
36
				'resultMessage' => null,
37
			])
38
		);
39
40 1
		$data = $response->getData();
41
42 1
		return new EchoResponse(
43 1
			DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']),
0 ignored issues
show
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

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