Conditions | 4 |
Paths | 5 |
Total Lines | 53 |
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 |
||
61 | public function validInputProvider() { |
||
62 | $gregorian = 'http://www.wikidata.org/entity/Q1985727'; |
||
63 | $julian = 'http://www.wikidata.org/entity/Q1985786'; |
||
64 | |||
65 | $argLists = array(); |
||
66 | |||
67 | $valid = array( |
||
68 | // Whitespace |
||
69 | "1999\n" => |
||
70 | array( '+1999-00-00T00:00:00Z' ), |
||
71 | ' 2000 ' => |
||
72 | array( '+2000-00-00T00:00:00Z' ), |
||
73 | |||
74 | '2010' => |
||
75 | array( '+2010-00-00T00:00:00Z' ), |
||
76 | '2000000' => |
||
77 | array( '+2000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M ), |
||
78 | '2000000000' => |
||
79 | array( '+2000000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1G ), |
||
80 | '2000020000' => |
||
81 | array( '+2000020000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR10K ), |
||
82 | '2000001' => |
||
83 | array( '+2000001-00-00T00:00:00Z' ), |
||
84 | '02000001' => |
||
85 | array( '+2000001-00-00T00:00:00Z' ), |
||
86 | '1' => |
||
87 | array( '+0001-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
88 | '000000001' => |
||
89 | array( '+0001-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
90 | '-1000000' => |
||
91 | array( '-1000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M, $julian ), |
||
92 | '-1 000 000' => |
||
93 | array( '-1000000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1M, $julian ), |
||
94 | '-19_000' => |
||
95 | array( '-19000-00-00T00:00:00Z', TimeValue::PRECISION_YEAR1K, $julian ), |
||
96 | // Digit grouping in the Indian numbering system |
||
97 | '-1,99,999' => |
||
98 | array( '-199999-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, $julian ), |
||
99 | ); |
||
100 | |||
101 | foreach ( $valid as $value => $expected ) { |
||
102 | $timestamp = $expected[0]; |
||
103 | $precision = isset( $expected[1] ) ? $expected[1] : TimeValue::PRECISION_YEAR; |
||
104 | $calendarModel = isset( $expected[2] ) ? $expected[2] : $gregorian; |
||
105 | |||
106 | $argLists[] = array( |
||
107 | (string)$value, |
||
108 | new TimeValue( $timestamp, 0, 0, 0, $precision, $calendarModel ) |
||
109 | ); |
||
110 | } |
||
111 | |||
112 | return $argLists; |
||
113 | } |
||
114 | |||
172 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: