Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types = 1); |
||
23 | public function testRequestFormatting() |
||
24 | { |
||
25 | $receipt = new Receipt( |
||
26 | true, |
||
27 | 'CZ683555118', |
||
28 | '0/6460/ZQ42', |
||
29 | new \DateTimeImmutable('2016-11-01 00:30:12', new \DateTimeZone('Europe/Prague')), |
||
30 | 3411300 |
||
31 | ); |
||
32 | |||
33 | $this->crypto->method('getPkpCode') |
||
34 | ->willReturn('123'); |
||
35 | |||
36 | $this->crypto->method('getBkpCode') |
||
37 | ->willReturn('456'); |
||
38 | |||
39 | $request = new EvidenceRequest($receipt, $this->configuration, $this->crypto); |
||
40 | |||
41 | $requestData = $request->getRequestData(); |
||
42 | |||
43 | $this->assertArrayHasKey('Hlavicka', $requestData); |
||
44 | $this->assertArrayHasKey('Data', $requestData); |
||
45 | $this->assertArrayHasKey('KontrolniKody', $requestData); |
||
46 | $this->assertArrayHasKey('uuid_zpravy', $requestData['Hlavicka']); |
||
47 | $this->assertArrayHasKey('dat_odesl', $requestData['Hlavicka']); |
||
48 | |||
49 | unset($requestData['Hlavicka']['uuid_zpravy']); |
||
50 | unset($requestData['Hlavicka']['dat_odesl']); |
||
51 | |||
52 | $this->assertSame([ |
||
53 | 'prvni_zaslani' => true, |
||
54 | 'overeni' => true, |
||
55 | ], $requestData['Hlavicka']); |
||
56 | |||
57 | $this->assertSame([ |
||
58 | 'dic_popl' => 'CZ00000019', |
||
59 | 'dic_poverujiciho' => 'CZ683555118', |
||
60 | 'id_provoz' => '273', |
||
61 | 'id_pokl' => '/5546/RO24', |
||
62 | 'porad_cis' => '0/6460/ZQ42', |
||
63 | 'dat_trzby' => '2016-11-01T00:30:12+01:00', |
||
64 | 'celk_trzba' => '34113.00', |
||
65 | 'rezim' => 0, |
||
66 | ], $requestData['Data']); |
||
67 | |||
68 | $this->assertSame([ |
||
69 | 'pkp' => [ |
||
70 | '_' => '123', |
||
71 | 'digest' => 'SHA256', |
||
72 | 'cipher' => 'RSA2048', |
||
73 | 'encoding' => 'base64', |
||
74 | ], |
||
75 | 'bkp' => [ |
||
76 | '_' => '456', |
||
77 | 'digest' => 'SHA1', |
||
78 | 'encoding' => 'base16', |
||
79 | ], |
||
80 | ], $requestData['KontrolniKody']); |
||
81 | |||
82 | } |
||
83 | |||
85 |