| Conditions | 2 |
| Paths | 2 |
| Total Lines | 72 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 |
||
| 15 | public function testGet() |
||
| 16 | { |
||
| 17 | $client = \Mockery::mock(GuzzleClient::class); |
||
| 18 | $client |
||
| 19 | ->shouldReceive('request') |
||
| 20 | ->once() |
||
| 21 | ->with('GET', sprintf('%s/%s/leads.json', Resource::ENDPOINT_LEADS, Resource::PREFIX), $this->getQuery([ |
||
| 22 | 'query' => [ |
||
| 23 | 'page' => 1 |
||
| 24 | ] |
||
| 25 | ])) |
||
| 26 | ->andReturn($this->getResponse(200, ' |
||
| 27 | { |
||
| 28 | "success": true, |
||
| 29 | "metadata": { |
||
| 30 | "count": 2 |
||
| 31 | }, |
||
| 32 | "items": [ |
||
| 33 | { |
||
| 34 | "success": true, |
||
| 35 | "lead": { |
||
| 36 | "id": 1, |
||
| 37 | "user_id": 2, |
||
| 38 | "account_id": 3, |
||
| 39 | "owner_id": 2, |
||
| 40 | "first_name": "Lead", |
||
| 41 | "last_name": "One", |
||
| 42 | "company_name": null, |
||
| 43 | "created_at": "2013-04-10T15:04:24+00:00", |
||
| 44 | "state": null, |
||
| 45 | "display_name": "Lead One", |
||
| 46 | "conversion_name": "Lead One", |
||
| 47 | "added_on": "2013-04-10T15:04:24+00:00" |
||
| 48 | }, |
||
| 49 | "metadata": { |
||
| 50 | } |
||
| 51 | }, |
||
| 52 | { |
||
| 53 | "success": true, |
||
| 54 | "lead": { |
||
| 55 | "id": 2, |
||
| 56 | "user_id": 2, |
||
| 57 | "account_id": 3, |
||
| 58 | "owner_id": 2, |
||
| 59 | "first_name": "Lead", |
||
| 60 | "last_name": "Two", |
||
| 61 | "company_name": null, |
||
| 62 | "created_at": "2013-04-10T15:04:00+00:00", |
||
| 63 | "state": null, |
||
| 64 | "display_name": "Lead Two", |
||
| 65 | "conversion_name": "Lead Two", |
||
| 66 | "added_on": "2013-04-10T15:04:00+00:00" |
||
| 67 | }, |
||
| 68 | "metadata": { |
||
| 69 | } |
||
| 70 | } |
||
| 71 | ] |
||
| 72 | } |
||
| 73 | ')); |
||
| 74 | |||
| 75 | $baseCrm = new BaseCrm('', $client); |
||
| 76 | $leads = $baseCrm->getLeads(); |
||
| 77 | $found = 0; |
||
| 78 | /** @var Lead $lead */ |
||
| 79 | foreach ($leads as $lead) |
||
| 80 | { |
||
| 81 | $this->assertInstanceOf(Lead::class, $lead); |
||
| 82 | $this->assertEquals($found + 1, $lead->id); |
||
| 83 | ++$found; |
||
| 84 | } |
||
| 85 | $this->assertEquals(2, $found); |
||
| 86 | } |
||
| 87 | |||
| 264 |
This check looks for
@paramannotations 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.