| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| 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 constructorProvider() |
||
| 36 | { |
||
| 37 | $start01 = new DateTime('2019-01-06'); |
||
| 38 | $start02 = new DateTime('2019-01-07'); |
||
| 39 | $start03 = new DateTime('2019-01-07'); |
||
| 40 | $start04 = new DateTime('2019-01-01'); |
||
| 41 | $start05 = new DateTime('2019-01-27'); |
||
| 42 | |||
| 43 | $end01 = new DateTime('2019-01-12'); |
||
| 44 | $end02 = new DateTime('2019-01-11'); |
||
| 45 | $end03 = new DateTime('2019-01-13'); |
||
| 46 | $end04 = new DateTime('2019-01-05'); |
||
| 47 | $end05 = new DateTime('2019-01-31'); |
||
| 48 | |||
| 49 | $expectedDays01 = 5; |
||
| 50 | $expectedDays02 = 7; |
||
| 51 | $expectedDays03 = 6; |
||
| 52 | $expectedDays04 = 3; |
||
| 53 | $expectedDays05 = 4; |
||
| 54 | |||
| 55 | $configDays01 = [ |
||
| 56 | new DayNumber(DayNumber::MONDAY), |
||
| 57 | new DayNumber(DayNumber::TUESDAY), |
||
| 58 | new DayNumber(DayNumber::WEDNESDAY), |
||
| 59 | new DayNumber(DayNumber::THURSDAY), |
||
| 60 | new DayNumber(DayNumber::FRIDAY) |
||
| 61 | ]; |
||
| 62 | |||
| 63 | $configDays02 = [ |
||
| 64 | new DayNumber(DayNumber::TUESDAY), |
||
| 65 | new DayNumber(DayNumber::WEDNESDAY), |
||
| 66 | new DayNumber(DayNumber::THURSDAY) |
||
| 67 | ]; |
||
| 68 | |||
| 69 | $configDays03 = [ |
||
| 70 | new DayNumber(DayNumber::MONDAY), |
||
| 71 | new DayNumber(DayNumber::TUESDAY), |
||
| 72 | new DayNumber(DayNumber::WEDNESDAY), |
||
| 73 | new DayNumber(DayNumber::THURSDAY), |
||
| 74 | new DayNumber(DayNumber::FRIDAY), |
||
| 75 | new DayNumber(DayNumber::SATURDAY) |
||
| 76 | ]; |
||
| 77 | |||
| 78 | $tz01 = new DateTimeZone('UTC'); |
||
| 79 | $tz02 = new DateTimeZone('America/Sao_Paulo'); |
||
| 80 | |||
| 81 | $config01 = new DatesConfig($tz01, new DayNumber(DayNumber::SUNDAY), $configDays01); |
||
| 82 | $config02 = new DatesConfig($tz01, new DayNumber(DayNumber::SUNDAY), $configDays02); |
||
| 83 | $config03 = new DatesConfig($tz01, new DayNumber(DayNumber::SUNDAY), $configDays03); |
||
| 84 | $config04 = new DatesConfig($tz02, new DayNumber(DayNumber::SUNDAY), $configDays01); |
||
| 85 | |||
| 86 | return [ |
||
| 87 | [$start01, $end01, $config01, $expectedDays01, $expectedDays02], |
||
| 88 | [$start02, $end02, $config02, $expectedDays04, $expectedDays01], |
||
| 89 | [$start03, $end03, $config03, $expectedDays03, $expectedDays02], |
||
| 90 | [$start01, $end01, $config04, $expectedDays01, $expectedDays02], |
||
| 91 | [$start04, $end04, $config01, $expectedDays05, $expectedDays01], |
||
| 92 | [$start05, $end05, $config01, $expectedDays05, $expectedDays01] |
||
| 93 | ]; |
||
| 94 | } |
||
| 95 | } |
||
| 96 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.