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