Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
195 | public function testTaggings() |
||
196 | { |
||
197 | $client = \Mockery::mock(GuzzleClient::class); |
||
198 | $client |
||
199 | ->shouldReceive('request') |
||
200 | ->once() |
||
201 | ->with('GET', sprintf('%s/%s/leads/1.json', Resource::ENDPOINT_LEADS, Resource::PREFIX), $this->getQuery()) |
||
202 | ->andReturn($this->getResponse(200, ' |
||
203 | { |
||
204 | "success": true, |
||
205 | "lead": { |
||
206 | "id": 1, |
||
207 | "user_id": 2, |
||
208 | "account_id": 3, |
||
209 | "owner_id": 2, |
||
210 | "first_name": "Lead", |
||
211 | "last_name": "One", |
||
212 | "company_name": null, |
||
213 | "created_at": "2013-04-10T15:04:24+00:00", |
||
214 | "state": null, |
||
215 | "display_name": "Lead One", |
||
216 | "conversion_name": "Lead One", |
||
217 | "added_on": "2013-04-10T15:04:24+00:00" |
||
218 | }, |
||
219 | "metadata": { |
||
220 | } |
||
221 | } |
||
222 | ')); |
||
223 | $baseCrm = new BaseCrm('', $client); |
||
224 | /** @var Lead $lead */ |
||
225 | $lead = $baseCrm->getLeads()->get(1); |
||
226 | $this->assertInstanceOf(Lead::class, $lead); |
||
227 | $this->assertEquals(1, $lead->id); |
||
228 | |||
229 | $client |
||
230 | ->shouldReceive('request') |
||
231 | ->once() |
||
232 | ->with('POST', sprintf('%s/%s/taggings.json', Resource::ENDPOINT_TAGS, Resource::PREFIX), $this->getQuery([ |
||
233 | 'query' => [ |
||
234 | 'app_id' => 5, |
||
235 | 'taggable_type' => 'Lead', |
||
236 | 'taggable_id' => 1, |
||
237 | 'tag_list' => 'tag1,tag2', |
||
238 | ], |
||
239 | ])) |
||
240 | ->andReturn($this->getResponse(200, ' |
||
241 | [ |
||
242 | { |
||
243 | "tag": { |
||
244 | "id": 1, |
||
245 | "name": "tag1", |
||
246 | "permissions_holder_id": 20 |
||
247 | } |
||
248 | }, |
||
249 | { |
||
250 | "tag": { |
||
251 | "id": 2, |
||
252 | "name": "tag2", |
||
253 | "permissions_holder_id": 20 |
||
254 | } |
||
255 | } |
||
256 | ] |
||
257 | ')); |
||
258 | |||
259 | $tags = $lead->saveTags(['tag1', 'tag2']); |
||
260 | $this->assertInstanceOf(ResourceCollection::class, $tags); |
||
261 | $this->assertCount(2, $tags); |
||
262 | } |
||
263 | } |
||
264 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.