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