| Conditions | 5 |
| Paths | 9 |
| Total Lines | 61 |
| 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 |
||
| 37 | public function validProvider() { |
||
| 38 | $gregorian = 'http://www.wikidata.org/entity/Q1985727'; |
||
| 39 | $julian = 'http://www.wikidata.org/entity/Q1985786'; |
||
| 40 | |||
| 41 | $baseOptions = new FormatterOptions(); |
||
| 42 | |||
| 43 | $tests = array( |
||
| 44 | '+2013-07-16T00:00:00Z' => array( |
||
| 45 | '+2013-07-16T00:00:00Z', |
||
| 46 | ), |
||
| 47 | '+0000-01-01T00:00:00Z' => array( |
||
| 48 | '+0000-01-01T00:00:00Z', |
||
| 49 | ), |
||
| 50 | |||
| 51 | // Different calendar models |
||
| 52 | '+0001-01-14T00:00:00Z' => array( |
||
| 53 | '+0001-01-14T00:00:00Z', |
||
| 54 | TimeValue::PRECISION_DAY, |
||
| 55 | $julian |
||
| 56 | ), |
||
| 57 | |||
| 58 | // Different years |
||
| 59 | '+10000-01-01T00:00:00Z' => array( |
||
| 60 | '+10000-01-01T00:00:00Z', |
||
| 61 | ), |
||
| 62 | '-0001-01-01T00:00:00Z' => array( |
||
| 63 | '-0001-01-01T00:00:00Z', |
||
| 64 | ), |
||
| 65 | |||
| 66 | // Different precisions |
||
| 67 | '+2013-07-17T00:00:00Z' => array( |
||
| 68 | '+2013-07-17T00:00:00Z', |
||
| 69 | TimeValue::PRECISION_MONTH, |
||
| 70 | ), |
||
| 71 | '+2013-07-18T00:00:00Z' => array( |
||
| 72 | '+2013-07-18T00:00:00Z', |
||
| 73 | TimeValue::PRECISION_YEAR, |
||
| 74 | ), |
||
| 75 | '+2013-07-19T00:00:00Z' => array( |
||
| 76 | '+2013-07-19T00:00:00Z', |
||
| 77 | TimeValue::PRECISION_YEAR10, |
||
| 78 | ), |
||
| 79 | ); |
||
| 80 | |||
| 81 | $argLists = array(); |
||
| 82 | |||
| 83 | foreach ( $tests as $expected => $args ) { |
||
| 84 | $timestamp = $args[0]; |
||
| 85 | $precision = isset( $args[1] ) ? $args[1] : TimeValue::PRECISION_DAY; |
||
| 86 | $calendarModel = isset( $args[2] ) ? $args[2] : $gregorian; |
||
| 87 | $options = isset( $args[3] ) ? $args[3] : $baseOptions; |
||
| 88 | |||
| 89 | $argLists[] = array( |
||
| 90 | new TimeValue( $timestamp, 0, 0, 0, $precision, $calendarModel ), |
||
| 91 | $expected, |
||
| 92 | $options |
||
| 93 | ); |
||
| 94 | } |
||
| 95 | |||
| 96 | return $argLists; |
||
| 97 | } |
||
| 98 | |||
| 123 |