Conditions | 5 |
Paths | 16 |
Total Lines | 236 |
Code Lines | 157 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 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 |
||
57 | public function __construct() { |
||
58 | $mapping = [ |
||
59 | SYNC_POOMCAL_TIMEZONE => [ |
||
60 | self::STREAMER_VAR => "timezone", |
||
61 | self::STREAMER_RONOTIFY => true, |
||
62 | ], |
||
63 | SYNC_POOMCAL_DTSTAMP => [ |
||
64 | self::STREAMER_VAR => "dtstamp", |
||
65 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
66 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO], |
||
67 | ], |
||
68 | SYNC_POOMCAL_STARTTIME => [ |
||
69 | self::STREAMER_VAR => "starttime", |
||
70 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
71 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME], |
||
72 | self::STREAMER_RONOTIFY => true, |
||
73 | ], |
||
74 | SYNC_POOMCAL_SUBJECT => [ |
||
75 | self::STREAMER_VAR => "subject", |
||
76 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY], |
||
77 | self::STREAMER_RONOTIFY => true, |
||
78 | self::STREAMER_PRIVATE => self::STRIP_PRIVATE_SUBSTITUTE, |
||
79 | ], |
||
80 | SYNC_POOMCAL_UID => [self::STREAMER_VAR => "uid"], |
||
81 | SYNC_POOMCAL_ORGANIZERNAME => [ |
||
82 | self::STREAMER_VAR => "organizername", // verified below |
||
83 | self::STREAMER_PRIVATE => 'Undisclosed Organizer', |
||
84 | ], |
||
85 | SYNC_POOMCAL_ORGANIZEREMAIL => [ |
||
86 | self::STREAMER_VAR => "organizeremail", // verified below |
||
87 | self::STREAMER_PRIVATE => 'undisclosed@localhost', |
||
88 | ], |
||
89 | SYNC_POOMCAL_LOCATION => [ |
||
90 | self::STREAMER_VAR => "location", |
||
91 | self::STREAMER_RONOTIFY => true, |
||
92 | self::STREAMER_PRIVATE => true, |
||
93 | ], |
||
94 | SYNC_POOMCAL_ENDTIME => [ |
||
95 | self::STREAMER_VAR => "endtime", |
||
96 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
97 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME], |
||
98 | self::STREAMER_RONOTIFY => true, |
||
99 | ], |
||
100 | SYNC_POOMCAL_RECURRENCE => [ |
||
101 | self::STREAMER_VAR => "recurrence", |
||
102 | self::STREAMER_TYPE => "SyncRecurrence", |
||
103 | self::STREAMER_RONOTIFY => true, |
||
104 | ], |
||
105 | // Sensitivity values |
||
106 | // 0 = Normal |
||
107 | // 1 = Personal |
||
108 | // 2 = Private |
||
109 | // 3 = Confident |
||
110 | SYNC_POOMCAL_SENSITIVITY => [ |
||
111 | self::STREAMER_VAR => "sensitivity", |
||
112 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3]], |
||
113 | self::STREAMER_RONOTIFY => true, |
||
114 | self::STREAMER_VALUEMAP => [0 => "Normal", |
||
115 | 1 => "Personal", |
||
116 | 2 => "Private", |
||
117 | 3 => "Confident", |
||
118 | ], |
||
119 | ], |
||
120 | // Busystatus values |
||
121 | // 0 = Free |
||
122 | // 1 = Tentative |
||
123 | // 2 = Busy |
||
124 | // 3 = Out of office |
||
125 | // 4 = Working Elsewhere |
||
126 | SYNC_POOMCAL_BUSYSTATUS => [ |
||
127 | self::STREAMER_VAR => "busystatus", |
||
128 | self::STREAMER_CHECKS => [ |
||
129 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
||
130 | self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3, 4], |
||
131 | ], |
||
132 | self::STREAMER_RONOTIFY => true, |
||
133 | // if private is stripped, value will be set to 2 (busy) |
||
134 | self::STREAMER_PRIVATE => 2, |
||
135 | self::STREAMER_VALUEMAP => [ |
||
136 | 0 => "Free", |
||
137 | 1 => "Tentative", |
||
138 | 2 => "Busy", |
||
139 | 3 => "Out of office", |
||
140 | 4 => "Working Elsewhere", |
||
141 | ], |
||
142 | ], |
||
143 | SYNC_POOMCAL_ALLDAYEVENT => [ |
||
144 | self::STREAMER_VAR => "alldayevent", |
||
145 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO], |
||
146 | self::STREAMER_RONOTIFY => true, |
||
147 | self::STREAMER_VALUEMAP => [ |
||
148 | 0 => "No", |
||
149 | 1 => "Yes", |
||
150 | ], |
||
151 | ], |
||
152 | SYNC_POOMCAL_REMINDER => [ |
||
153 | self::STREAMER_VAR => "reminder", |
||
154 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_CMPHIGHER => -1], |
||
155 | self::STREAMER_RONOTIFY => true, |
||
156 | // if private is stripped, value will be unset (no reminder) |
||
157 | self::STREAMER_PRIVATE => true, |
||
158 | ], |
||
159 | // Meetingstatus values |
||
160 | // 0 = is not a meeting |
||
161 | // 1 = is a meeting |
||
162 | // 3 = Meeting received |
||
163 | // 5 = Meeting is canceled |
||
164 | // 7 = Meeting is canceled and received |
||
165 | // 9 = as 1 |
||
166 | // 11 = as 3 |
||
167 | // 13 = as 5 |
||
168 | // 15 = as 7 |
||
169 | SYNC_POOMCAL_MEETINGSTATUS => [ |
||
170 | self::STREAMER_VAR => "meetingstatus", |
||
171 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 3, 5, 7, 9, 11, 13, 15]], |
||
172 | self::STREAMER_RONOTIFY => true, |
||
173 | self::STREAMER_VALUEMAP => [ |
||
174 | 0 => "Not a meeting", |
||
175 | 1 => "Meeting", |
||
176 | 3 => "Meeting received", |
||
177 | 5 => "Meeting canceled", |
||
178 | 7 => "Meeting canceled and received", |
||
179 | 9 => "Meeting", |
||
180 | 11 => "Meeting received", |
||
181 | 13 => "Meeting canceled", |
||
182 | 15 => "Meeting canceled and received", |
||
183 | ], |
||
184 | ], |
||
185 | SYNC_POOMCAL_ATTENDEES => [ |
||
186 | self::STREAMER_VAR => "attendees", |
||
187 | self::STREAMER_TYPE => "SyncAttendee", |
||
188 | self::STREAMER_ARRAY => SYNC_POOMCAL_ATTENDEE, |
||
189 | self::STREAMER_RONOTIFY => true, |
||
190 | self::STREAMER_PRIVATE => true, |
||
191 | ], |
||
192 | SYNC_POOMCAL_BODY => [ |
||
193 | self::STREAMER_VAR => "body", |
||
194 | self::STREAMER_RONOTIFY => true, |
||
195 | self::STREAMER_PRIVATE => true, |
||
196 | ], |
||
197 | SYNC_POOMCAL_BODYTRUNCATED => [ |
||
198 | self::STREAMER_VAR => "bodytruncated", |
||
199 | self::STREAMER_PRIVATE => true, |
||
200 | ], |
||
201 | SYNC_POOMCAL_EXCEPTIONS => [ |
||
202 | self::STREAMER_VAR => "exceptions", |
||
203 | self::STREAMER_TYPE => "SyncAppointmentException", |
||
204 | self::STREAMER_ARRAY => SYNC_POOMCAL_EXCEPTION, |
||
205 | self::STREAMER_RONOTIFY => true, |
||
206 | ], |
||
207 | SYNC_POOMCAL_CATEGORIES => [ |
||
208 | self::STREAMER_VAR => "categories", |
||
209 | self::STREAMER_ARRAY => SYNC_POOMCAL_CATEGORY, |
||
210 | self::STREAMER_RONOTIFY => true, |
||
211 | self::STREAMER_PRIVATE => true, |
||
212 | ], |
||
213 | ]; |
||
214 | |||
215 | if (Request::GetProtocolVersion() >= 12.0) { |
||
216 | $mapping[SYNC_AIRSYNCBASE_BODY] = [ |
||
217 | self::STREAMER_VAR => "asbody", |
||
218 | self::STREAMER_TYPE => "SyncBaseBody", |
||
219 | self::STREAMER_RONOTIFY => true, |
||
220 | self::STREAMER_PRIVATE => true, |
||
221 | ]; |
||
222 | |||
223 | $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = [self::STREAMER_VAR => "nativebodytype"]; |
||
224 | |||
225 | // unset these properties because airsyncbase body and attachments will be used instead |
||
226 | unset($mapping[SYNC_POOMCAL_BODY], $mapping[SYNC_POOMCAL_BODYTRUNCATED]); |
||
227 | } |
||
228 | |||
229 | if (Request::GetProtocolVersion() >= 14.0) { |
||
230 | $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = [ |
||
231 | self::STREAMER_VAR => "disallownewtimeprop", |
||
232 | self::STREAMER_RONOTIFY => true, |
||
233 | self::STREAMER_PRIVATE => 1, |
||
234 | ]; // don't permit new time proposal |
||
235 | $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = [ |
||
236 | self::STREAMER_VAR => "responserequested", |
||
237 | self::STREAMER_RONOTIFY => true, |
||
238 | ]; |
||
239 | $mapping[SYNC_POOMCAL_RESPONSETYPE] = [ |
||
240 | self::STREAMER_VAR => "responsetype", |
||
241 | self::STREAMER_RONOTIFY => true, |
||
242 | ]; |
||
243 | } |
||
244 | |||
245 | if (Request::GetProtocolVersion() >= 14.1) { |
||
246 | $mapping[SYNC_POOMCAL_ONLINEMEETINGCONFLINK] = [ |
||
247 | self::STREAMER_VAR => "onlineMeetingConfLink", |
||
248 | self::STREAMER_RONOTIFY => true, |
||
249 | ]; |
||
250 | $mapping[SYNC_POOMCAL_ONLINEMEETINGEXTERNALLINK] = [ |
||
251 | self::STREAMER_VAR => "onlineMeetingExternalLink", |
||
252 | self::STREAMER_RONOTIFY => true, |
||
253 | ]; |
||
254 | } |
||
255 | |||
256 | if (Request::GetProtocolVersion() >= 16.0) { |
||
257 | $mapping[SYNC_AIRSYNCBASE_ATTACHMENTS] = [ |
||
258 | self::STREAMER_VAR => "asattachments", |
||
259 | // Different tags can be used to encapsulate the SyncBaseAttachmentSubtypes depending on its usecase |
||
260 | self::STREAMER_ARRAY => [ |
||
261 | SYNC_AIRSYNCBASE_ATTACHMENT => "SyncBaseAttachment", |
||
262 | SYNC_AIRSYNCBASE_ADD => "SyncBaseAttachmentAdd", |
||
263 | SYNC_AIRSYNCBASE_DELETE => "SyncBaseAttachmentDelete", |
||
264 | ], |
||
265 | ]; |
||
266 | $mapping[SYNC_AIRSYNCBASE_LOCATION] = [ |
||
267 | self::STREAMER_VAR => "location2", |
||
268 | self::STREAMER_TYPE => "SyncLocation", |
||
269 | self::STREAMER_RONOTIFY => true, |
||
270 | ]; |
||
271 | $mapping[SYNC_POOMCAL_CLIENTUID] = [ |
||
272 | self::STREAMER_VAR => "clientuid", |
||
273 | self::STREAMER_RONOTIFY => true, |
||
274 | ]; |
||
275 | // Placeholder for the InstanceId (recurrence exceptions) and its deletion request |
||
276 | $mapping[SYNC_AIRSYNCBASE_INSTANCEID] = [ |
||
277 | self::STREAMER_VAR => "instanceid", |
||
278 | self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE, |
||
279 | ]; |
||
280 | $mapping[SYNC_AIRSYNCBASE_INSTANCEID_DELETE] = [ |
||
281 | self::STREAMER_VAR => "instanceiddelete", |
||
282 | self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE, |
||
283 | ]; |
||
284 | |||
285 | // unset these properties because airsyncbase location will be used instead |
||
286 | unset($mapping[SYNC_POOMCAL_LOCATION]); |
||
287 | } |
||
288 | |||
289 | parent::__construct($mapping); |
||
290 | |||
291 | // Indicates that this SyncObject supports the private flag and stripping of private data. |
||
292 | $this->supportsPrivateStripping = true; |
||
293 | } |
||
381 |