| 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 |
||
| 89 | protected function hydrateRecurringConfiguration(Configuration $configuration, array $rrule): void |
||
| 90 | { |
||
| 91 | foreach ($rrule as $key => $value) { |
||
| 92 | switch (strtoupper($key)) { |
||
| 93 | case 'FREQ': |
||
| 94 | // The spelling of the frequency in RFC 5545 matches the constants in ConfigurationInterface. |
||
| 95 | // Currently only a subset of frequencies is implemented (missing "SECONDLY" / "MINUTELY" / "HOURLY") |
||
| 96 | $configuration->setFrequency(strtolower($value)); |
||
| 97 | break; |
||
| 98 | case 'UNTIL': |
||
| 99 | try { |
||
| 100 | $tillDate = new \DateTime($value); |
||
| 101 | } catch (Exception $e) { |
||
| 102 | break; |
||
| 103 | } |
||
| 104 | if ($tillDate <= $configuration->getStartDate()) { |
||
| 105 | break; |
||
| 106 | } |
||
| 107 | |||
| 108 | $configuration->setTillDate(DateTimeUtility::getDayStart($tillDate)); |
||
| 109 | break; |
||
| 110 | case 'INTERVAL': |
||
| 111 | $interval = (int)$value; |
||
| 112 | if ($interval < 1) { |
||
| 113 | break; |
||
| 114 | } |
||
| 115 | |||
| 116 | $configuration->setCounterInterval($interval); |
||
| 117 | break; |
||
| 118 | case 'COUNT': |
||
| 119 | // RFC-5545 3.3.10: |
||
| 120 | // The COUNT rule part defines the number of occurrences at which to range-bound the recurrence. |
||
| 121 | // The "DTSTART" property value always counts as the first occurrence. |
||
| 122 | $count = (int)$value; |
||
| 123 | if ($count < 1) { |
||
| 124 | break; |
||
| 125 | } |
||
| 126 | |||
| 127 | // Since calendarize does not count the DTSTART as first occurrence, the count is decremented by one. |
||
| 128 | $configuration->setCounterAmount($count - 1); |
||
| 129 | break; |
||
| 130 | } |
||
| 131 | } |
||
| 132 | } |
||
| 133 | } |
||
| 134 |
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.