Conditions | 3 |
Paths | 3 |
Total Lines | 68 |
Code Lines | 48 |
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 |
||
33 | public function validProvider() { |
||
34 | $floats = [ |
||
35 | '55.755786, -37.617633' => [ 55.755786, -37.617633, 0.000001 ], |
||
36 | '-55.7558, 37.6176' => [ -55.755786, 37.617633, 0.0001 ], |
||
37 | '-55, -38' => [ -55, -37.617633, 1 ], |
||
38 | '5.5, 37' => [ 5.5, 37, 0.1 ], |
||
39 | '0, 0' => [ 0, 0, 1 ], |
||
40 | ]; |
||
41 | |||
42 | $decimalDegrees = [ |
||
43 | '55.755786°, 37.617633°' => [ 55.755786, 37.617633, 0.000001 ], |
||
44 | '55.7558°, -37.6176°' => [ 55.755786, -37.617633, 0.0001 ], |
||
45 | '-55°, -38°' => [ -55, -37.617633, 1 ], |
||
46 | '-5.5°, -37.0°' => [ -5.5, -37, 0.1 ], |
||
47 | '0°, 0°' => [ 0, 0, 1 ], |
||
48 | ]; |
||
49 | |||
50 | $dmsCoordinates = [ |
||
51 | '55° 45\' 20.830", 37° 37\' 3.479"' => [ 55.755786, 37.617633, 0.000001 ], |
||
52 | '55° 45\' 20.830", -37° 37\' 3.479"' => [ 55.755786, -37.617633, 0.000001 ], |
||
53 | '-55° 45\' 20.9", -37° 37\' 3.4"' => [ -55.755786, -37.617633, 0.0001 ], |
||
54 | '-55° 45\' 20.9", 37° 37\' 3.4"' => [ -55.755786, 37.617633, 0.0001 ], |
||
55 | |||
56 | '55°, 37°' => [ 55, 37, 1 ], |
||
57 | '55° 30\' 0", 37° 30\' 0"' => [ 55.5, 37.5, 0.01 ], |
||
58 | '55° 0\' 18", 37° 0\' 18"' => [ 55.005, 37.005, 0.001 ], |
||
59 | '0° 0\' 0", 0° 0\' 0"' => [ 0, 0, 0.001 ], |
||
60 | '0° 0\' 18", 0° 0\' 18"' => [ 0.005, 0.005, 0.001 ], |
||
61 | '-0° 0\' 18", -0° 0\' 18"' => [ -0.005, -0.005, 0.001 ], |
||
62 | ]; |
||
63 | |||
64 | $dmCoordinates = [ |
||
65 | '55°, 37°' => [ 55, 37, 1 ], |
||
66 | '0°, 0°' => [ 0, 0, 1 ], |
||
67 | '55° 31\', 37° 31\'' => [ 55.5, 37.5, 0.04 ], |
||
68 | '-55° 31\', -37° 31\'' => [ -55.5, -37.5, 0.04 ], |
||
69 | '-0° 0.3\', -0° 0.3\'' => [ -0.005, -0.005, 0.005 ], |
||
70 | ]; |
||
71 | |||
72 | $argLists = []; |
||
73 | |||
74 | $tests = [ |
||
75 | LatLongFormatter::TYPE_FLOAT => $floats, |
||
76 | LatLongFormatter::TYPE_DD => $decimalDegrees, |
||
77 | LatLongFormatter::TYPE_DMS => $dmsCoordinates, |
||
78 | LatLongFormatter::TYPE_DM => $dmCoordinates, |
||
79 | ]; |
||
80 | |||
81 | $i = 0; |
||
82 | foreach ( $tests as $format => $coords ) { |
||
83 | foreach ( $coords as $expectedOutput => $arguments ) { |
||
84 | $options = new FormatterOptions(); |
||
85 | $options->setOption( LatLongFormatter::OPT_FORMAT, $format ); |
||
86 | |||
87 | $input = new GlobeCoordinateValue( |
||
88 | new LatLongValue( $arguments[0], $arguments[1] ), |
||
89 | $arguments[2] |
||
90 | ); |
||
91 | |||
92 | $key = "[$i] $format: $expectedOutput"; |
||
93 | $argLists[$key] = [ $input, $expectedOutput, $options ]; |
||
94 | |||
95 | $i++; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | return $argLists; |
||
100 | } |
||
101 | |||
135 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.