Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
23 | public function fetchUsingEdge() |
||
24 | { |
||
25 | $mockResponse = $this->getMockResponse( |
||
26 | [ |
||
27 | 'edge-country' => 'america/new_york', |
||
28 | 'edge-region' => 'usa', |
||
29 | 'edge-city' => 'radford', |
||
30 | 'edge-conn-speed' => 'broadband', |
||
31 | 'edge-metro-code' => '2', |
||
32 | 'edge-latitude' => '123.456', |
||
33 | 'edge-longitude' => '789.101', |
||
34 | 'edge-postal-code' => '24141', |
||
35 | 'edge-country-code' => '112', |
||
36 | 'edge-region-code' => '1314', |
||
37 | 'edge-city-code' => '1516', |
||
38 | 'edge-continent-code' => '1', |
||
39 | 'edge-two-letter-country' => 'US', |
||
40 | 'edge-area-codes' => '540', |
||
41 | 'edge-country-conf' => '30039', |
||
42 | 'edge-region-conf' => '33.9056', |
||
43 | 'edge-city-conf' => '99', |
||
44 | 'edge-postal-conf' => '99', |
||
45 | 'edge-gmt-offset' => '-500', |
||
46 | 'edge-in-dst' => 'n', |
||
47 | 'edge-timezone-name' => 't3', |
||
48 | ] |
||
49 | ); |
||
50 | $mockClient = $this->getMockGuzzleClient(); |
||
51 | $mockClient->method('send')->willReturn($mockResponse); |
||
|
|||
52 | |||
53 | $database = new EdgeDatabase($mockClient, 'a token'); |
||
54 | $actual = $database->fetch('192.168.1.1'); |
||
55 | |||
56 | $expected = [ |
||
57 | 'area-code' => '540', |
||
58 | 'city' => 'radford', |
||
59 | 'city-code' => '1516', |
||
60 | 'city-conf' => '99', |
||
61 | 'conn-speed' => 'broadband', |
||
62 | 'continent-code' => '1', |
||
63 | 'country' => 'america/new_york', |
||
64 | 'country-code' => '112', |
||
65 | 'country-conf' => '30039', |
||
66 | 'gmt-offset' => '-500', |
||
67 | 'in-dist' => 'n', |
||
68 | 'latitude' => '123.456', |
||
69 | 'longitude' => '789.101', |
||
70 | 'metro-code' => '2', |
||
71 | 'postal-conf' => '99', |
||
72 | 'region' => 'usa', |
||
73 | 'region-code' => '1314', |
||
74 | 'region-conf' => '33.9056', |
||
75 | 'timezone-name' => 't3', |
||
76 | 'two-letter-country' => 'US', |
||
77 | 'zip-code' => '24141', |
||
78 | ]; |
||
79 | |||
80 | $this->assertSame($expected, $actual); |
||
81 | } |
||
82 | |||
187 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.