| Conditions | 10 | 
| Paths | 10 | 
| Total Lines | 44 | 
| 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 | ||
| 84 | protected static function hydrateRecurringConfiguration(Configuration $configuration, array $rrule): void | ||
| 85 |     { | ||
| 86 |         foreach ($rrule as $key => $value) { | ||
| 87 |             switch (strtoupper($key)) { | ||
| 88 | case 'FREQ': | ||
| 89 | // The spelling of the frequency in RFC 5545 matches the constants in ConfigurationInterface. | ||
| 90 | // Currently only a subset of frequencies is implemented (missing "SECONDLY" / "MINUTELY" / "HOURLY") | ||
| 91 | $configuration->setFrequency(strtolower($value)); | ||
| 92 | break; | ||
| 93 | case 'UNTIL': | ||
| 94 |                     try { | ||
| 95 | $tillDate = new \DateTime($value); | ||
| 96 |                     } catch (Exception $e) { | ||
| 97 | break; | ||
| 98 | } | ||
| 99 |                     if ($tillDate <= $configuration->getStartDate()) { | ||
| 100 | break; | ||
| 101 | } | ||
| 102 | |||
| 103 | $configuration->setTillDate(DateTimeUtility::getDayStart($tillDate)); | ||
| 104 | break; | ||
| 105 | case 'INTERVAL': | ||
| 106 | $interval = (int)$value; | ||
| 107 |                     if ($interval < 1) { | ||
| 108 | break; | ||
| 109 | } | ||
| 110 | |||
| 111 | $configuration->setCounterInterval($interval); | ||
| 112 | break; | ||
| 113 | case 'COUNT': | ||
| 114 | // RFC-5545 3.3.10: | ||
| 115 | // The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. | ||
| 116 | // The "DTSTART" property value always counts as the first occurrence. | ||
| 117 | $count = (int)$value; | ||
| 118 |                     if ($count < 1) { | ||
| 119 | break; | ||
| 120 | } | ||
| 121 | |||
| 122 | // Since calendarize does not count the DTSTART as first occurrence, the count is decremented by one. | ||
| 123 | $configuration->setCounterAmount($count - 1); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 128 | } | ||
| 129 | 
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.