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