Conditions | 4 |
Paths | 5 |
Total Lines | 51 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
67 | public function validInputProvider() { |
||
68 | $gregorian = 'http://www.wikidata.org/entity/Q1985727'; |
||
69 | $julian = 'http://www.wikidata.org/entity/Q1985786'; |
||
70 | |||
71 | $argLists = array(); |
||
72 | |||
73 | $valid = array( |
||
74 | '1999' => |
||
75 | array( '+1999-00-00T00:00:00Z' ), |
||
76 | '2000' => |
||
77 | array( '+2000-00-00T00:00:00Z' ), |
||
78 | '2010' => |
||
79 | array( '+2010-00-00T00:00:00Z' ), |
||
80 | '2000000' => |
||
81 | array( '+2000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M ), |
||
82 | '2000000000' => |
||
83 | array( '+2000000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1G ), |
||
84 | '2000020000' => |
||
85 | array( '+2000020000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR10K ), |
||
86 | '2000001' => |
||
87 | array( '+2000001-00-00T00:00:00Z' ), |
||
88 | '02000001' => |
||
89 | array( '+2000001-00-00T00:00:00Z' ), |
||
90 | '1' => |
||
91 | array( '+0001-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
92 | '000000001' => |
||
93 | array( '+0001-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
94 | '-1000000' => |
||
95 | array( '-1000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M, $julian ), |
||
96 | '-1 000 000' => |
||
97 | array( '-1000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M, $julian ), |
||
98 | '-19_000' => |
||
99 | array( '-19000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1K, $julian ), |
||
100 | // Digit grouping in the Indian numbering system |
||
101 | '-1,99,999' => |
||
102 | array( '-199999-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
103 | ); |
||
104 | |||
105 | foreach ( $valid as $value => $expected ) { |
||
106 | $timestamp = $expected[0]; |
||
107 | $precision = isset( $expected[1] ) ? $expected[1] : TimeValue::PRECISION_YEAR; |
||
108 | $calendarModel = isset( $expected[2] ) ? $expected[2] : $gregorian; |
||
109 | |||
110 | $argLists[] = array( |
||
111 | (string)$value, |
||
112 | new TimeValue( $timestamp, 0, 0, 0, $precision, $calendarModel ) |
||
113 | ); |
||
114 | } |
||
115 | |||
116 | return $argLists; |
||
117 | } |
||
118 | |||
179 |