getFormatDataForSignatureData()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 113
Code Lines 66

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 66
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 113
rs 8.7418

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Crypto;
4
5
use PHPUnit\Framework\TestCase;
6
7
class SignatureDataFormatterTest extends TestCase
8
{
9
10
	/**
11
	 * @return mixed[]
12
	 */
13
	public function getFormatDataForSignatureData(): array
14
	{
15
		return [
16
			[
17
				[
18
					'id' => null,
19
					'name' => null,
20
				],
21
				[
22
					'id' => 123,
23
					'name' => 'foo',
24
				],
25
				'123|foo',
26
			],
27
			[
28
				[
29
					'id' => null,
30
					'name' => null,
31
				],
32
				[
33
					'name' => 'foo',
34
					'id' => 123,
35
				],
36
				'123|foo',
37
			],
38
			[
39
				[
40
					'id' => null,
41
					'name' => null,
42
				],
43
				[
44
					'name' => 'foo',
45
					'id' => 123,
46
					'date' => '2015-10-10',
47
				],
48
				'123|foo',
49
			],
50
			[
51
				[
52
					'id' => null,
53
					'name' => null,
54
					'date' => null,
55
				],
56
				[
57
					'name' => 'foo',
58
					'id' => 123,
59
				],
60
				'123|foo',
61
			],
62
			[
63
				[
64
					'id' => null,
65
					'name' => null,
66
					'cart' => [
67
						[
68
							'name' => null,
69
							'price' => null,
70
						],
71
					],
72
					'description' => null,
73
				],
74
				[
75
					'name' => 'foo',
76
					'id' => 123,
77
					'cart' => [
78
						[
79
							'price' => 99,
80
							'name' => 'foo product',
81
						],
82
						[
83
							'name' => 'bar product',
84
						],
85
					],
86
					'description' => 'order description',
87
				],
88
				'123|foo|foo product|99|bar product|order description',
89
			],
90
			[
91
				[
92
					'payId' => null,
93
					'dttm' => null,
94
					'resultCode' => null,
95
					'resultMessage' => null,
96
					'paymentStatus' => null,
97
					'lightboxParams' => [
98
						'requestToken' => null,
99
						'callbackUrl' => null,
100
						'merchantCheckoutId' => null,
101
						'allowedCardTypes' => null,
102
						'suppressShippingAddressEnable' => null,
103
						'loyaltyEnabled' => null,
104
						'version' => null,
105
						'shippingLocationProfile' => null,
106
					],
107
				],
108
				[
109
					'dttm' => '2017',
110
					'payId' => '123',
111
					'resultCode' => 0,
112
					'resultMessage' => 'OK',
113
					'paymentStatus' => 1,
114
					'lightboxParams' => [
115
						'requestToken' => '261666',
116
						'callbackUrl' => 'https:/example.com/',
117
						'merchantCheckoutId' => 'DUMMY',
118
						'allowedCardTypes' => 'visa,master',
119
						'suppressShippingAddressEnable' => 'true',
120
						'loyaltyEnabled' => 'false',
121
						'version' => 'v6',
122
						'shippingLocationProfile' => 'SP-0001',
123
					],
124
				],
125
				'123|2017|0|OK|1|261666|https:/example.com/|DUMMY|visa,master|true|false|v6|SP-0001',
126
			],
127
		];
128
	}
129
130
	/**
131
	 * @dataProvider getFormatDataForSignatureData
132
	 *
133
	 * @param mixed[] $keyPriority
134
	 * @param mixed[] $data
135
	 * @param string $expectedData
136
	 */
137
	public function testFormatDataForSignature(array $keyPriority, array $data, string $expectedData): void
138
	{
139
		$signatureDataFormatter = new SignatureDataFormatter($keyPriority);
140
141
		self::assertSame($expectedData, $signatureDataFormatter->formatDataForSignature($data));
142
	}
143
144
}
145