Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
Code Lines | 56 |
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 |
||
83 | // Original and duplicate lists have the same content |
||
84 | $this->assertListEquals( |
||
85 | $caribouList, |
||
86 | $orig->caribou() |
||
87 | ); |
||
88 | $this->assertListEquals( |
||
89 | $caribouList, |
||
90 | $duplicate->caribou() |
||
91 | ); |
||
92 | // Ids of each record are the same (only mapping content is duplicated) |
||
93 | $this->assertEquals( |
||
94 | $orig->caribou()->getIDList(), |
||
95 | $duplicate->caribou()->getIDList() |
||
96 | ); |
||
97 | |||
98 | // Ensure 'five' belongs_to is duplicated |
||
99 | $fiveOne = $this->objFromFixture(DataObjectDuplicationTest\Elephant::class, 'one'); |
||
100 | $fiveOneDuplicate = $duplicate->elephant(); |
||
101 | $this->assertNotEmpty($fiveOneDuplicate); |
||
102 | $this->assertEquals('Elephant one', $fiveOneDuplicate->Title); |
||
103 | $this->assertNotEquals($fiveOne->ID, $fiveOneDuplicate->ID); |
||
104 | |||
105 | // Ensure 'five.Child' is duplicated |
||
106 | $sixOne = $this->objFromFixture(DataObjectDuplicationTest\Frog::class, 'one'); |
||
107 | $sixOneDuplicate = $fiveOneDuplicate->Child(); |
||
108 | $this->assertNotEmpty($sixOneDuplicate); |
||
109 | $this->assertEquals('Frog one', $sixOneDuplicate->Title); |
||
110 | $this->assertNotEquals($sixOne->ID, $sixOneDuplicate->ID); |
||
111 | } |
||
112 | } |
||
113 |