| Conditions | 3 |
| Paths | 4 |
| Total Lines | 121 |
| Code Lines | 62 |
| 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 |
||
| 28 | public function __construct() { |
||
| 29 | $mapping = [ |
||
| 30 | SYNC_POOMTASKS_START => [self::STREAMER_VAR => "start", |
||
| 31 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
| 32 | self::STREAMER_RONOTIFY => true, ], |
||
| 33 | |||
| 34 | // Recurrence type |
||
| 35 | // 0 = Recurs daily |
||
| 36 | // 1 = Recurs weekly |
||
| 37 | // 2 = Recurs monthly |
||
| 38 | // 3 = Recurs monthly on the nth day |
||
| 39 | // 5 = Recurs yearly |
||
| 40 | // 6 = Recurs yearly on the nth day |
||
| 41 | SYNC_POOMTASKS_TYPE => [ |
||
| 42 | self::STREAMER_VAR => "type", |
||
| 43 | self::STREAMER_CHECKS => [ |
||
| 44 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
||
| 45 | self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3, 5, 6], |
||
| 46 | ], |
||
| 47 | self::STREAMER_RONOTIFY => true, |
||
| 48 | ], |
||
| 49 | SYNC_POOMTASKS_UNTIL => [ |
||
| 50 | self::STREAMER_VAR => "until", |
||
| 51 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
| 52 | self::STREAMER_RONOTIFY => true, |
||
| 53 | ], |
||
| 54 | SYNC_POOMTASKS_OCCURRENCES => [ |
||
| 55 | self::STREAMER_VAR => "occurrences", |
||
| 56 | self::STREAMER_CHECKS => [ |
||
| 57 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
| 58 | self::STREAMER_CHECK_CMPLOWER => 1000, |
||
| 59 | ], |
||
| 60 | self::STREAMER_RONOTIFY => true, |
||
| 61 | ], |
||
| 62 | SYNC_POOMTASKS_INTERVAL => [ |
||
| 63 | self::STREAMER_VAR => "interval", |
||
| 64 | self::STREAMER_CHECKS => [ |
||
| 65 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
| 66 | self::STREAMER_CHECK_CMPLOWER => 1000, |
||
| 67 | ], |
||
| 68 | self::STREAMER_RONOTIFY => true, |
||
| 69 | ], |
||
| 70 | // TODO: check iOS5 sends deadoccur inside of the recurrence |
||
| 71 | SYNC_POOMTASKS_DEADOCCUR => [ |
||
| 72 | self::STREAMER_VAR => "deadoccur", |
||
| 73 | self::STREAMER_RONOTIFY => true, |
||
| 74 | ], |
||
| 75 | SYNC_POOMTASKS_REGENERATE => [ |
||
| 76 | self::STREAMER_VAR => "regenerate", |
||
| 77 | self::STREAMER_RONOTIFY => true, |
||
| 78 | ], |
||
| 79 | // DayOfWeek values |
||
| 80 | // 1 = Sunday |
||
| 81 | // 2 = Monday |
||
| 82 | // 4 = Tuesday |
||
| 83 | // 8 = Wednesday |
||
| 84 | // 16 = Thursday |
||
| 85 | // 32 = Friday |
||
| 86 | // 62 = Weekdays // TODO check: value set by WA with daily weekday recurrence |
||
| 87 | // 64 = Saturday |
||
| 88 | // 127 = The last day of the month. Value valid only in monthly or yearly recurrences. |
||
| 89 | SYNC_POOMTASKS_DAYOFWEEK => [ |
||
| 90 | self::STREAMER_VAR => "dayofweek", |
||
| 91 | self::STREAMER_CHECKS => [ |
||
| 92 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
| 93 | self::STREAMER_CHECK_CMPLOWER => 128, |
||
| 94 | ], |
||
| 95 | self::STREAMER_RONOTIFY => true, |
||
| 96 | ], |
||
| 97 | // DayOfMonth values |
||
| 98 | // 1-31 representing the day |
||
| 99 | SYNC_POOMTASKS_DAYOFMONTH => [ |
||
| 100 | self::STREAMER_VAR => "dayofmonth", |
||
| 101 | self::STREAMER_CHECKS => [ |
||
| 102 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
| 103 | self::STREAMER_CHECK_CMPLOWER => 32, |
||
| 104 | ], |
||
| 105 | self::STREAMER_RONOTIFY => true, |
||
| 106 | ], |
||
| 107 | // WeekOfMonth |
||
| 108 | // 1-4 = Y st/nd/rd/th week of month |
||
| 109 | // 5 = last week of month |
||
| 110 | SYNC_POOMTASKS_WEEKOFMONTH => [ |
||
| 111 | self::STREAMER_VAR => "weekofmonth", |
||
| 112 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [1, 2, 3, 4, 5]], |
||
| 113 | self::STREAMER_RONOTIFY => true, |
||
| 114 | ], |
||
| 115 | // MonthOfYear |
||
| 116 | // 1-12 representing the month |
||
| 117 | SYNC_POOMTASKS_MONTHOFYEAR => [ |
||
| 118 | self::STREAMER_VAR => "monthofyear", |
||
| 119 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]], |
||
| 120 | self::STREAMER_RONOTIFY => true, |
||
| 121 | ], |
||
| 122 | ]; |
||
| 123 | |||
| 124 | if (Request::GetProtocolVersion() >= 14.0) { |
||
| 125 | $mapping[SYNC_POOMTASKS_CALENDARTYPE] = [ |
||
| 126 | self::STREAMER_VAR => "calendartype", |
||
| 127 | self::STREAMER_RONOTIFY => true, |
||
| 128 | ]; |
||
| 129 | } |
||
| 130 | |||
| 131 | if (Request::GetProtocolVersion() >= 14.1) { |
||
| 132 | // First day of the calendar week for recurrence. |
||
| 133 | // FirstDayOfWeek values: |
||
| 134 | // 0 = Sunday |
||
| 135 | // 1 = Monday |
||
| 136 | // 2 = Tuesday |
||
| 137 | // 3 = Wednesday |
||
| 138 | // 4 = Thursday |
||
| 139 | // 5 = Friday |
||
| 140 | // 6 = Saturday |
||
| 141 | $mapping[SYNC_POOMTASKS_FIRSTDAYOFWEEK] = [ |
||
| 142 | self::STREAMER_VAR => "firstdayofweek", |
||
| 143 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3, 4, 5, 6]], |
||
| 144 | self::STREAMER_RONOTIFY => true, |
||
| 145 | ]; |
||
| 146 | } |
||
| 147 | |||
| 148 | parent::__construct($mapping); |
||
| 149 | } |
||
| 182 |