@@ -14,14 +14,14 @@ class Calendar implements DataTypeInterface
14
14
*
15
15
* @var string
16
16
*/
17
- protected $ prefix = " BEGIN:VEVENT " ;
17
+ protected $ prefix = ' BEGIN:VEVENT ' ;
18
18
19
19
/**
20
20
* The suffix of the QrCode.
21
21
*
22
22
* @var string
23
23
*/
24
- protected $ suffix = " END:VEVENT " ;
24
+ protected $ suffix = ' END:VEVENT ' ;
25
25
26
26
/**
27
27
* The separator between the variables.
@@ -53,23 +53,23 @@ class Calendar implements DataTypeInterface
53
53
54
54
/**
55
55
* The start time of the event.
56
- * e.g 2020-05-23 15:00
56
+ * e.g 2020-05-23 15:00.
57
57
*
58
58
* @var string
59
59
*/
60
60
protected $ startDateTime ;
61
61
62
62
/**
63
63
* The end time of the event.
64
- * e.g 2020-05-24 15:00
64
+ * e.g 2020-05-24 15:00.
65
65
*
66
66
* @var string
67
67
*/
68
68
protected $ endDateTime ;
69
69
70
70
/**
71
71
* Start/End date timezone.
72
- * e.g 'Africa/Douala'
72
+ * e.g 'Africa/Douala'.
73
73
*
74
74
* @var string
75
75
*/
@@ -81,7 +81,7 @@ class Calendar implements DataTypeInterface
81
81
*
82
82
* @var string
83
83
*/
84
- protected $ dateTimeFormat = " Y-m-d H:i " ;
84
+ protected $ dateTimeFormat = ' Y-m-d H:i ' ;
85
85
86
86
/**
87
87
* Event full descriptions/notes.
@@ -98,7 +98,7 @@ class Calendar implements DataTypeInterface
98
98
protected $ categories ;
99
99
100
100
/**
101
- * Alarm/Reminder. Trigger's before/after event
101
+ * Alarm/Reminder. Trigger's before/after event.
102
102
*
103
103
* @var array
104
104
*/
@@ -134,33 +134,33 @@ protected function buildCalendarString()
134
134
$ calendar = $ this ->prefix .$ this ->separator ;
135
135
136
136
if (isset ($ this ->summary )) {
137
- $ calendar .= " SUMMARY: " .$ this ->summary .$ this ->separator ;
137
+ $ calendar .= ' SUMMARY: ' .$ this ->summary .$ this ->separator ;
138
138
}
139
139
if (isset ($ this ->startDateTime )) {
140
- $ calendar .= " DTSTART " ;
140
+ $ calendar .= ' DTSTART ' ;
141
141
if (isset ($ this ->timezone )) {
142
142
$ calendar .= $ this ->timezone ;
143
143
}
144
- $ calendar .= " : " .$ this ->startDateTime .$ this ->separator ;
144
+ $ calendar .= ' : ' .$ this ->startDateTime .$ this ->separator ;
145
145
}
146
146
if (isset ($ this ->endDateTime )) {
147
- $ calendar .= " DTEND " ;
147
+ $ calendar .= ' DTEND ' ;
148
148
if (isset ($ this ->timezone )) {
149
149
$ calendar .= $ this ->timezone ;
150
150
}
151
- $ calendar .= " : " .$ this ->endDateTime .$ this ->separator ;
151
+ $ calendar .= ' : ' .$ this ->endDateTime .$ this ->separator ;
152
152
}
153
153
if (isset ($ this ->location )) {
154
- $ calendar .= " LOCATION: " .$ this ->location .$ this ->separator ;
154
+ $ calendar .= ' LOCATION: ' .$ this ->location .$ this ->separator ;
155
155
}
156
156
if (isset ($ this ->url )) {
157
- $ calendar .= " URL: " .$ this ->url .$ this ->separator ;
157
+ $ calendar .= ' URL: ' .$ this ->url .$ this ->separator ;
158
158
}
159
159
if (isset ($ this ->description )) {
160
- $ calendar .= " DESCRIPTION: " .$ this ->description .$ this ->separator ;
160
+ $ calendar .= ' DESCRIPTION: ' .$ this ->description .$ this ->separator ;
161
161
}
162
162
if (isset ($ this ->categories )) {
163
- $ calendar .= " CATEGORIES: " .$ this ->categories .$ this ->separator ;
163
+ $ calendar .= ' CATEGORIES: ' .$ this ->categories .$ this ->separator ;
164
164
}
165
165
if (isset ($ this ->alarm )) {
166
166
$ calendar .= $ this ->alarm ;
@@ -193,10 +193,10 @@ protected function setProperties(array $arguments)
193
193
}
194
194
195
195
$ this ->summary = $ arguments ['summary ' ];
196
- $ this ->setEventDateTime ($ arguments ['startDateTime ' ], " start " );
196
+ $ this ->setEventDateTime ($ arguments ['startDateTime ' ], ' start ' );
197
197
198
198
if (isset ($ arguments ['endDateTime ' ])) {
199
- $ this ->setEventDateTime ($ arguments ['endDateTime ' ], " end " );
199
+ $ this ->setEventDateTime ($ arguments ['endDateTime ' ], ' end ' );
200
200
}
201
201
if (isset ($ arguments ['location ' ])) {
202
202
$ this ->location = $ arguments ['location ' ];
@@ -235,13 +235,13 @@ protected function setUrl($url)
235
235
* @param string $type
236
236
*
237
237
*/
238
- protected function setEventDateTime ($ eventDateTime , $ type = "" )
238
+ protected function setEventDateTime ($ eventDateTime , $ type = '' )
239
239
{
240
240
if ($ this ->isValidDateTime ($ eventDateTime , $ type )) {
241
- if ($ type == " start " ) {
241
+ if ($ type == ' start ' ) {
242
242
$ this ->startDateTime = $ this ->convertEventDateTimeToString ($ eventDateTime );
243
243
}
244
- if ($ type == " end " ) {
244
+ if ($ type == ' end ' ) {
245
245
$ this ->endDateTime = $ this ->convertEventDateTimeToString ($ eventDateTime );
246
246
}
247
247
}
@@ -271,15 +271,15 @@ protected function isValidUrl($url)
271
271
*
272
272
* @return bool
273
273
*/
274
- protected function isValidDateTime ($ dateTime , $ type = "" )
274
+ protected function isValidDateTime ($ dateTime , $ type = '' )
275
275
{
276
276
$ newDate = DateTime::createFromFormat ($ this ->dateTimeFormat , $ dateTime );
277
277
if (! ($ newDate && $ newDate ->format ($ this ->dateTimeFormat ) == $ dateTime )) {
278
- if ($ type == " start " ) {
278
+ if ($ type == ' start ' ) {
279
279
throw new InvalidArgumentException ('Invalid start date provided. Date must be of format ' .
280
280
$ this ->dateTimeFormat );
281
281
}
282
- if ($ type == " end " ) {
282
+ if ($ type == ' end ' ) {
283
283
throw new InvalidArgumentException ('Invalid end date provided. Date must be of format ' .
284
284
$ this ->dateTimeFormat );
285
285
}
@@ -292,7 +292,7 @@ protected function isValidDateTime($dateTime, $type = "")
292
292
293
293
294
294
/**
295
- * Returns correct date time to string
295
+ * Returns correct date time to string.
296
296
*
297
297
* @param string $dateTime
298
298
*
@@ -309,7 +309,7 @@ protected function convertEventDateTimeToString($dateTime)
309
309
}
310
310
311
311
/**
312
- * Ensures timezone string is valid. ('Africa/Douala')
312
+ * Ensures timezone string is valid. ('Africa/Douala').
313
313
*
314
314
* @param string $timezone
315
315
*
@@ -331,7 +331,7 @@ protected function isValidTimeZone($timezone)
331
331
protected function setEventTimeZone ($ timezone )
332
332
{
333
333
if ($ this ->isValidTimeZone ($ timezone )) {
334
- $ this ->timezone = " ;TZID= " .$ timezone ;
334
+ $ this ->timezone = ' ;TZID= ' .$ timezone ;
335
335
}
336
336
}
337
337
@@ -343,17 +343,17 @@ protected function setEventTimeZone($timezone)
343
343
protected function setAlarm ($ alarm )
344
344
{
345
345
if (is_array ($ alarm )) {
346
- $ alarmString = " BEGIN:VALARM " .$ this ->separator ;
347
- $ alarmString .= " ACTION:DISPLAY " .$ this ->separator ;
348
- $ alarmString .= $ this ->keyExists (" repeat " , $ alarm ) ?
349
- " REPEAT: " .$ alarm [" repeat " ].$ this ->separator : "" ;
350
- $ alarmString .= $ this ->keyExists (" summary " , $ alarm ) ?
351
- " SUMMARY: " .$ alarm [" summary " ].$ this ->separator : "" ;
352
- $ alarmString .= $ this ->keyExists (" description " , $ alarm ) ?
353
- " DESCRIPTION: " .$ alarm [" description " ].$ this ->separator : "" ;
354
- if ($ this ->keyExists (" trigger " , $ alarm ) && is_array ($ alarm [" trigger " ]))
355
- $ alarmString .= $ this ->setAlarmTrigger ($ alarm [" trigger " ]).$ this ->separator ;
356
- $ alarmString .= " END:VALARM " .$ this ->separator ;
346
+ $ alarmString = ' BEGIN:VALARM ' .$ this ->separator ;
347
+ $ alarmString .= ' ACTION:DISPLAY ' .$ this ->separator ;
348
+ $ alarmString .= $ this ->keyExists (' repeat ' , $ alarm ) ?
349
+ ' REPEAT: ' .$ alarm [' repeat ' ].$ this ->separator : '' ;
350
+ $ alarmString .= $ this ->keyExists (' summary ' , $ alarm ) ?
351
+ ' SUMMARY: ' .$ alarm [' summary ' ].$ this ->separator : '' ;
352
+ $ alarmString .= $ this ->keyExists (' description ' , $ alarm ) ?
353
+ ' DESCRIPTION: ' .$ alarm [' description ' ].$ this ->separator : '' ;
354
+ if ($ this ->keyExists (' trigger ' , $ alarm ) && is_array ($ alarm [' trigger ' ]))
355
+ $ alarmString .= $ this ->setAlarmTrigger ($ alarm [' trigger ' ]).$ this ->separator ;
356
+ $ alarmString .= ' END:VALARM ' .$ this ->separator ;
357
357
$ this ->alarm = $ alarmString ;
358
358
} else {
359
359
throw new InvalidArgumentException ('Invalid alarm provided. ' );
@@ -369,15 +369,15 @@ protected function setAlarm($alarm)
369
369
protected function setAlarmTrigger ($ alarm )
370
370
{
371
371
if (is_array ($ alarm )) {
372
- $ alarmString = " TRIGGER: " ;
373
- $ alarmString .= $ this ->keyExists (" before " , $ alarm ) ? $ alarm [" before " ] ? " - " : "" : " - " ;
374
- $ alarmString .= " P " ;
375
- $ alarmString .= $ this ->keyExists (" weeks " , $ alarm ) ? $ alarm [" weeks " ]. " W " : "" ;
376
- $ alarmString .= $ this ->keyExists (" days " , $ alarm ) ? $ alarm [" days " ]. " D " : "" ;
377
- $ alarmString .= " T " ;
378
- $ alarmString .= $ this ->keyExists (" hours " , $ alarm ) ? $ alarm [" hours " ]. " H " : "" ;
379
- $ alarmString .= $ this ->keyExists (" minutes " , $ alarm ) ? $ alarm [" minutes " ]. " M " : "" ;
380
- $ alarmString .= $ this ->keyExists (" seconds " , $ alarm ) ? $ alarm [" seconds " ]. " S " : "" ;
372
+ $ alarmString = ' TRIGGER: ' ;
373
+ $ alarmString .= $ this ->keyExists (' before ' , $ alarm ) ? $ alarm [' before ' ] ? ' - ' : '' : '' ;
374
+ $ alarmString .= ' P ' ;
375
+ $ alarmString .= $ this ->keyExists (' weeks ' , $ alarm ) ? $ alarm [' weeks ' ]. ' W ' : '' ;
376
+ $ alarmString .= $ this ->keyExists (' days ' , $ alarm ) ? $ alarm [' days ' ]. ' D ' : '' ;
377
+ $ alarmString .= ' T ' ;
378
+ $ alarmString .= $ this ->keyExists (' hours ' , $ alarm ) ? $ alarm [' hours ' ]. ' H ' : '' ;
379
+ $ alarmString .= $ this ->keyExists (' minutes ' , $ alarm ) ? $ alarm [' minutes ' ]. ' M ' : '' ;
380
+ $ alarmString .= $ this ->keyExists (' seconds ' , $ alarm ) ? $ alarm [' seconds ' ]. ' S ' : '' ;
381
381
return $ alarmString ;
382
382
} else {
383
383
throw new InvalidArgumentException ('Invalid alarm duration provided. ' );
@@ -392,7 +392,7 @@ protected function setAlarmTrigger($alarm)
392
392
protected function setCategories ($ categories )
393
393
{
394
394
if (is_array ($ categories )) {
395
- $ this ->categories = implode (" , " , $ categories );
395
+ $ this ->categories = implode (' , ' , $ categories );
396
396
} else {
397
397
throw new InvalidArgumentException ('Invalid categories provided. ' );
398
398
}
@@ -401,12 +401,13 @@ protected function setCategories($categories)
401
401
/**
402
402
* Checks if key exists in array.
403
403
*
404
- * @param string $key;
404
+ * @param string $key
405
405
* @param array $array
406
406
*
407
- * @return boolean
407
+ * @return bool
408
408
*/
409
- protected function keyExists ($ key , $ array ) {
409
+ protected function keyExists ($ key , $ array )
410
+ {
410
411
return array_key_exists ($ key , $ array );
411
412
}
412
413
}
0 commit comments