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