Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
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 |
||
24 | public function testSuppress() |
||
25 | { |
||
26 | $snapshot = $this->makeSnapshot('message', 123); |
||
27 | |||
28 | $this->handleSnapshot($snapshot, true); |
||
29 | $record = $this->handleSnapshot($snapshot, true); |
||
30 | |||
31 | $this->assertEquals(2, $record->count_occurred); |
||
32 | $this->assertCount(1, $record->getIncidentsHistory()); |
||
33 | |||
34 | /** @var IncidentRecord $incident */ |
||
35 | $incident = iterator_to_array($record->getIncidentsHistory())[0]; |
||
36 | |||
37 | $this->assertNotEmpty($incident); |
||
38 | $this->assertNotEmpty($incident->getExceptionSource()); |
||
39 | $this->assertTrue($incident->status->isStored()); |
||
40 | |||
41 | //Suppress new history record |
||
42 | $record->setSuppression(true); |
||
43 | $record->save(); |
||
44 | |||
45 | $record = $this->handleSnapshot($snapshot, true); |
||
46 | |||
47 | $this->assertEquals(3, $record->count_occurred); |
||
48 | $this->assertCount(2, $record->getIncidentsHistory()); |
||
49 | |||
50 | $incident = iterator_to_array($record->getIncidentsHistory())[0]; |
||
51 | |||
52 | $this->assertNotEmpty($incident); |
||
53 | $this->assertNotEmpty($incident->getExceptionSource()); |
||
54 | $this->assertTrue($incident->status->isStored()); |
||
55 | |||
56 | $incident = iterator_to_array($record->getIncidentsHistory())[1]; |
||
57 | |||
58 | $this->assertNotEmpty($incident); |
||
59 | $this->assertEmpty($incident->getExceptionSource()); |
||
60 | $this->assertFalse($incident->status->isStored()); |
||
61 | $this->assertTrue($incident->status->isSuppressed()); |
||
62 | |||
63 | //Don't suppress new history record |
||
64 | $record->setSuppression(false); |
||
65 | $record->save(); |
||
66 | |||
67 | $record = $this->handleSnapshot($snapshot, true); |
||
68 | |||
69 | $this->assertEquals(4, $record->count_occurred); |
||
70 | $this->assertCount(3, $record->getIncidentsHistory()); |
||
71 | |||
72 | $incident = iterator_to_array($record->getIncidentsHistory())[0]; |
||
73 | |||
74 | $this->assertNotEmpty($incident); |
||
75 | $this->assertNotEmpty($incident->getExceptionSource()); |
||
76 | $this->assertTrue($incident->status->isStored()); |
||
77 | |||
78 | $incident = iterator_to_array($record->getIncidentsHistory())[1]; |
||
79 | |||
80 | $this->assertNotEmpty($incident); |
||
81 | $this->assertEmpty($incident->getExceptionSource()); |
||
82 | $this->assertFalse($incident->status->isStored()); |
||
83 | $this->assertTrue($incident->status->isSuppressed()); |
||
84 | |||
85 | $incident = iterator_to_array($record->getIncidentsHistory())[2]; |
||
86 | |||
87 | $this->assertNotEmpty($incident); |
||
88 | $this->assertNotEmpty($incident->getExceptionSource()); |
||
89 | $this->assertTrue($incident->status->isStored()); |
||
90 | } |
||
91 | } |