Conditions | 1 |
Paths | 1 |
Total Lines | 69 |
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); |
||
21 | public function testRequestFormatting(): void |
||
22 | { |
||
23 | $receipt = new Receipt( |
||
24 | true, |
||
25 | 'CZ683555118', |
||
26 | '0/6460/ZQ42', |
||
27 | new DateTimeImmutable('2016-11-01 00:30:12', new DateTimeZone('Europe/Prague')), |
||
28 | 3411300 |
||
29 | ); |
||
30 | |||
31 | $crypto = $this->createMock(CryptographyService::class); |
||
32 | $crypto->method('getPkpCode') |
||
|
|||
33 | ->willReturn('123'); |
||
34 | |||
35 | $crypto->method('getBkpCode') |
||
36 | ->willReturn('456'); |
||
37 | |||
38 | $request = new EvidenceRequest($receipt, $this->configuration, $crypto); |
||
39 | |||
40 | $requestData = $request->getRequestData(); |
||
41 | |||
42 | $this->assertArrayHasKey('Hlavicka', $requestData); |
||
43 | $this->assertArrayHasKey('Data', $requestData); |
||
44 | $this->assertArrayHasKey('KontrolniKody', $requestData); |
||
45 | $headerData = $requestData['Hlavicka']; |
||
46 | $this->assertArrayHasKey('uuid_zpravy', $headerData); |
||
47 | $this->assertArrayHasKey('dat_odesl', $headerData); |
||
48 | |||
49 | $this->assertSame($headerData, $request->getHeader()); |
||
50 | unset($headerData['uuid_zpravy']); |
||
51 | unset($headerData['dat_odesl']); |
||
52 | |||
53 | $this->assertSame([ |
||
54 | 'prvni_zaslani' => true, |
||
55 | 'overeni' => true, |
||
56 | ], $headerData); |
||
57 | |||
58 | $this->assertSame([ |
||
59 | 'dic_popl' => 'CZ00000019', |
||
60 | 'dic_poverujiciho' => 'CZ683555118', |
||
61 | 'id_provoz' => '273', |
||
62 | 'id_pokl' => '/5546/RO24', |
||
63 | 'porad_cis' => '0/6460/ZQ42', |
||
64 | 'dat_trzby' => '2016-11-01T00:30:12+01:00', |
||
65 | 'celk_trzba' => '34113.00', |
||
66 | 'rezim' => 0, |
||
67 | ], $requestData['Data']); |
||
68 | |||
69 | $this->assertSame($requestData['Data'], $request->getBody()); |
||
70 | |||
71 | $this->assertSame([ |
||
72 | 'pkp' => [ |
||
73 | '_' => '123', |
||
74 | 'digest' => 'SHA256', |
||
75 | 'cipher' => 'RSA2048', |
||
76 | 'encoding' => 'base64', |
||
77 | ], |
||
78 | 'bkp' => [ |
||
79 | '_' => '456', |
||
80 | 'digest' => 'SHA1', |
||
81 | 'encoding' => 'base16', |
||
82 | ], |
||
83 | ], $requestData['KontrolniKody']); |
||
84 | |||
85 | $this->assertSame('123', $request->getPkpCode()); |
||
86 | $this->assertSame('456', $request->getBkpCode()); |
||
87 | |||
88 | $this->assertInstanceOf(DateTimeImmutable::class, $request->getSendDate()); |
||
89 | } |
||
90 | |||
92 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.