Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 43 |
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 |
||
107 | public function testRemoveDuplicates() |
||
108 | { |
||
109 | Injector::inst()->get(URLArrayObject::class)->addUrls(array( |
||
110 | 'test1' => 1, |
||
111 | 'test2' => 1, |
||
112 | 'test3' => 1 |
||
113 | )); |
||
114 | Injector::inst()->get(URLArrayObject::class)->addUrls(array( |
||
115 | 'test2' => 2, // duplicate |
||
116 | 'test3' => 2, // duplicate |
||
117 | )); |
||
118 | Injector::inst()->get(URLArrayObject::class)->addUrls(array( |
||
119 | 'test2' => 3, // duplicate |
||
120 | )); |
||
121 | $test1Objs = StaticPagesQueue::get()->filter(array( |
||
122 | 'URLSegment' => 'test1' |
||
123 | ))->first(); |
||
124 | $test2Objs = StaticPagesQueue::get()->filter(array( |
||
125 | 'URLSegment' => 'test2' |
||
126 | ))->first(); |
||
127 | $test3Objs = StaticPagesQueue::get()->filter(array( |
||
128 | 'URLSegment' => 'test3' |
||
129 | ))->first(); |
||
130 | $this->assertCount(1, $test1Objs); |
||
131 | $this->assertCount(3, $test2Objs); |
||
132 | $this->assertCount(2, $test3Objs); |
||
133 | |||
134 | StaticPagesQueue::remove_duplicates($test1Objs->first()->ID); |
||
135 | $test1Objs = StaticPagesQueue::get()->filter(array( |
||
136 | 'URLSegment' => 'test1' |
||
137 | ))->first(); |
||
138 | $test2Objs = StaticPagesQueue::get()->filter(array( |
||
139 | 'URLSegment' => 'test2' |
||
140 | ))->first(); |
||
141 | $test3Objs = StaticPagesQueue::get()->filter(array( |
||
142 | 'URLSegment' => 'test3' |
||
143 | ))->first(); |
||
144 | $this->assertCount(1, $test1Objs); |
||
145 | $this->assertCount(3, $test2Objs); |
||
146 | $this->assertCount(2, $test3Objs); |
||
147 | |||
148 | StaticPagesQueue::remove_duplicates($test2Objs->first()->ID); |
||
149 | $test2Objs = StaticPagesQueue::get()->filter(array( |
||
150 | 'URLSegment' => 'test2' |
||
151 | )); |
||
152 | $this->assertCount(1, $test2Objs); |
||
153 | |||
154 | StaticPagesQueue::remove_duplicates($test3Objs->first()->ID); |
||
155 | $test3Objs = StaticPagesQueue::get()->filter(array( |
||
156 | 'URLSegment' => 'test3' |
||
157 | )); |
||
158 | $this->assertCount(1, $test3Objs); |
||
159 | } |
||
160 | } |
||
161 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.