Conditions | 2 |
Paths | 2 |
Total Lines | 73 |
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 |
||
31 | public function validInputProvider() { |
||
32 | $valid = [ |
||
33 | // Whitespace |
||
34 | "1N 1E\n" => new LatLongValue( 1, 1 ), |
||
35 | ' 1N 1E ' => new LatLongValue( 1, 1 ), |
||
36 | |||
37 | // Float |
||
38 | '55.7557860 N, 37.6176330 W' => new LatLongValue( 55.7557860, -37.6176330 ), |
||
39 | '55.7557860, -37.6176330' => new LatLongValue( 55.7557860, -37.6176330 ), |
||
40 | '55 S, 37.6176330 W' => new LatLongValue( -55, -37.6176330 ), |
||
41 | '-55, -37.6176330' => new LatLongValue( -55, -37.6176330 ), |
||
42 | '5.5S,37W ' => new LatLongValue( -5.5, -37 ), |
||
43 | '-5.5,-37 ' => new LatLongValue( -5.5, -37 ), |
||
44 | '4,2' => new LatLongValue( 4, 2 ), |
||
45 | '5.5S 37W ' => new LatLongValue( -5.5, -37 ), |
||
46 | '-5.5 -37 ' => new LatLongValue( -5.5, -37 ), |
||
47 | '4 2' => new LatLongValue( 4, 2 ), |
||
48 | 'S5.5 W37 ' => new LatLongValue( -5.5, -37 ), |
||
49 | |||
50 | // DD |
||
51 | '55.7557860° N, 37.6176330° W' => new LatLongValue( 55.7557860, -37.6176330 ), |
||
52 | '55.7557860°, -37.6176330°' => new LatLongValue( 55.7557860, -37.6176330 ), |
||
53 | '55° S, 37.6176330 ° W' => new LatLongValue( -55, -37.6176330 ), |
||
54 | '-55°, -37.6176330 °' => new LatLongValue( -55, -37.6176330 ), |
||
55 | '5.5°S,37°W ' => new LatLongValue( -5.5, -37 ), |
||
56 | '-5.5°,-37° ' => new LatLongValue( -5.5, -37 ), |
||
57 | '-55° -37.6176330 °' => new LatLongValue( -55, -37.6176330 ), |
||
58 | '5.5°S 37°W ' => new LatLongValue( -5.5, -37 ), |
||
59 | '-5.5 ° -37 ° ' => new LatLongValue( -5.5, -37 ), |
||
60 | 'S5.5° W37°' => new LatLongValue( -5.5, -37 ), |
||
61 | |||
62 | // DMS |
||
63 | '55° 45\' 20.8296", 37° 37\' 3.4788"' => new LatLongValue( 55.755786, 37.6176330000 ), |
||
64 | '55° 45\' 20.8296", -37° 37\' 3.4788"' => new LatLongValue( 55.755786, -37.6176330000 ), |
||
65 | '-55° 45\' 20.8296", -37° 37\' 3.4788"' => new LatLongValue( -55.755786, -37.6176330000 ), |
||
66 | '-55° 45\' 20.8296", 37° 37\' 3.4788"' => new LatLongValue( -55.755786, 37.6176330000 ), |
||
67 | '55° 0\' 0", 37° 0\' 0"' => new LatLongValue( 55, 37 ), |
||
68 | '55° 30\' 0", 37° 30\' 0"' => new LatLongValue( 55.5, 37.5 ), |
||
69 | '55° 0\' 18", 37° 0\' 18"' => new LatLongValue( 55.005, 37.005 ), |
||
70 | '0° 0\' 0", 0° 0\' 0"' => new LatLongValue( 0, 0 ), |
||
71 | '0° 0\' 18" N, 0° 0\' 18" E' => new LatLongValue( 0.005, 0.005 ), |
||
72 | ' 0° 0\' 18" S , 0° 0\' 18" W ' => new LatLongValue( -0.005, -0.005 ), |
||
73 | '0° 0′ 18″ N, 0° 0′ 18″ E' => new LatLongValue( 0.005, 0.005 ), |
||
74 | '0° 0\' 18" N 0° 0\' 18" E' => new LatLongValue( 0.005, 0.005 ), |
||
75 | ' 0 ° 0 \' 18 " S 0 ° 0 \' 18 " W ' => new LatLongValue( -0.005, -0.005 ), |
||
76 | '0° 0′ 18″ N 0° 0′ 18″ E' => new LatLongValue( 0.005, 0.005 ), |
||
77 | 'N 0° 0\' 18" E 0° 0\' 18"' => new LatLongValue( 0.005, 0.005 ), |
||
78 | |||
79 | // DM |
||
80 | '55° 0\', 37° 0\'' => new LatLongValue( 55, 37 ), |
||
81 | '55° 30\', 37° 30\'' => new LatLongValue( 55.5, 37.5 ), |
||
82 | '0° 0\', 0° 0\'' => new LatLongValue( 0, 0 ), |
||
83 | '-55° 30\', -37° 30\'' => new LatLongValue( -55.5, -37.5 ), |
||
84 | '0° 0.3\' S, 0° 0.3\' W' => new LatLongValue( -0.005, -0.005 ), |
||
85 | '-55° 30′, -37° 30′' => new LatLongValue( -55.5, -37.5 ), |
||
86 | '-55 ° 30 \' -37 ° 30 \'' => new LatLongValue( -55.5, -37.5 ), |
||
87 | '0° 0.3\' S 0° 0.3\' W' => new LatLongValue( -0.005, -0.005 ), |
||
88 | '-55° 30′ -37° 30′' => new LatLongValue( -55.5, -37.5 ), |
||
89 | 'S 0° 0.3\' W 0° 0.3\'' => new LatLongValue( -0.005, -0.005 ), |
||
90 | |||
91 | // Case insensitivity |
||
92 | '55 s, 37.6176330 w' => new LatLongValue( -55, -37.6176330 ), |
||
93 | '5.5s,37w ' => new LatLongValue( -5.5, -37 ), |
||
94 | '5.5s 37w ' => new LatLongValue( -5.5, -37 ), |
||
95 | 's5.5 w37 ' => new LatLongValue( -5.5, -37 ), |
||
96 | '5.5S 37w ' => new LatLongValue( -5.5, -37 ), |
||
97 | '5.5s 37W ' => new LatLongValue( -5.5, -37 ), |
||
98 | ]; |
||
99 | |||
100 | foreach ( $valid as $input => $expected ) { |
||
101 | yield [ $input, $expected ]; |
||
102 | } |
||
103 | } |
||
104 | |||
134 |