@@ -137,12 +137,13 @@ public function getCreator()
137
137
/**
138
138
* Set Creator
139
139
*
140
- * @param string $pValue
140
+ * @param string $value
141
141
* @return self
142
142
*/
143
- public function setCreator ($ pValue = '' )
143
+ public function setCreator ($ value = '' )
144
144
{
145
- $ this ->creator = $ pValue ;
145
+ $ this ->creator = $ this ->setValue ($ value , '' );
146
+
146
147
return $ this ;
147
148
}
148
149
@@ -159,12 +160,13 @@ public function getLastModifiedBy()
159
160
/**
160
161
* Set Last Modified By
161
162
*
162
- * @param string $pValue
163
+ * @param string $value
163
164
* @return self
164
165
*/
165
- public function setLastModifiedBy ($ pValue = '' )
166
+ public function setLastModifiedBy ($ value = '' )
166
167
{
167
- $ this ->lastModifiedBy = $ pValue ;
168
+ $ this ->lastModifiedBy = $ this ->setValue ($ value , '' );
169
+
168
170
return $ this ;
169
171
}
170
172
@@ -181,15 +183,13 @@ public function getCreated()
181
183
/**
182
184
* Set Created
183
185
*
184
- * @param int $pValue
186
+ * @param int $value
185
187
* @return self
186
188
*/
187
- public function setCreated ($ pValue = null )
189
+ public function setCreated ($ value = null )
188
190
{
189
- if (is_null ($ pValue )) {
190
- $ pValue = time ();
191
- }
192
- $ this ->created = $ pValue ;
191
+ $ this ->created = $ this ->setValue ($ value , time ());
192
+
193
193
return $ this ;
194
194
}
195
195
@@ -206,15 +206,13 @@ public function getModified()
206
206
/**
207
207
* Set Modified
208
208
*
209
- * @param int $pValue
209
+ * @param int $value
210
210
* @return self
211
211
*/
212
- public function setModified ($ pValue = null )
212
+ public function setModified ($ value = null )
213
213
{
214
- if (is_null ($ pValue )) {
215
- $ pValue = time ();
216
- }
217
- $ this ->modified = $ pValue ;
214
+ $ this ->modified = $ this ->setValue ($ value , time ());
215
+
218
216
return $ this ;
219
217
}
220
218
@@ -231,12 +229,13 @@ public function getTitle()
231
229
/**
232
230
* Set Title
233
231
*
234
- * @param string $pValue
232
+ * @param string $value
235
233
* @return self
236
234
*/
237
- public function setTitle ($ pValue = '' )
235
+ public function setTitle ($ value = '' )
238
236
{
239
- $ this ->title = $ pValue ;
237
+ $ this ->title = $ this ->setValue ($ value , '' );
238
+
240
239
return $ this ;
241
240
}
242
241
@@ -253,12 +252,13 @@ public function getDescription()
253
252
/**
254
253
* Set Description
255
254
*
256
- * @param string $pValue
255
+ * @param string $value
257
256
* @return self
258
257
*/
259
- public function setDescription ($ pValue = '' )
258
+ public function setDescription ($ value = '' )
260
259
{
261
- $ this ->description = $ pValue ;
260
+ $ this ->description = $ this ->setValue ($ value , '' );
261
+
262
262
return $ this ;
263
263
}
264
264
@@ -275,12 +275,13 @@ public function getSubject()
275
275
/**
276
276
* Set Subject
277
277
*
278
- * @param string $pValue
278
+ * @param string $value
279
279
* @return self
280
280
*/
281
- public function setSubject ($ pValue = '' )
281
+ public function setSubject ($ value = '' )
282
282
{
283
- $ this ->subject = $ pValue ;
283
+ $ this ->subject = $ this ->setValue ($ value , '' );
284
+
284
285
return $ this ;
285
286
}
286
287
@@ -297,12 +298,13 @@ public function getKeywords()
297
298
/**
298
299
* Set Keywords
299
300
*
300
- * @param string $pValue
301
+ * @param string $value
301
302
* @return self
302
303
*/
303
- public function setKeywords ($ pValue = '' )
304
+ public function setKeywords ($ value = '' )
304
305
{
305
- $ this ->keywords = $ pValue ;
306
+ $ this ->keywords = $ this ->setValue ($ value , '' );
307
+
306
308
return $ this ;
307
309
}
308
310
@@ -319,12 +321,13 @@ public function getCategory()
319
321
/**
320
322
* Set Category
321
323
*
322
- * @param string $pValue
324
+ * @param string $value
323
325
* @return self
324
326
*/
325
- public function setCategory ($ pValue = '' )
327
+ public function setCategory ($ value = '' )
326
328
{
327
- $ this ->category = $ pValue ;
329
+ $ this ->category = $ this ->setValue ($ value , '' );
330
+
328
331
return $ this ;
329
332
}
330
333
@@ -341,12 +344,13 @@ public function getCompany()
341
344
/**
342
345
* Set Company
343
346
*
344
- * @param string $pValue
347
+ * @param string $value
345
348
* @return self
346
349
*/
347
- public function setCompany ($ pValue = '' )
350
+ public function setCompany ($ value = '' )
348
351
{
349
- $ this ->company = $ pValue ;
352
+ $ this ->company = $ this ->setValue ($ value , '' );
353
+
350
354
return $ this ;
351
355
}
352
356
@@ -363,12 +367,13 @@ public function getManager()
363
367
/**
364
368
* Set Manager
365
369
*
366
- * @param string $pValue
370
+ * @param string $value
367
371
* @return self
368
372
*/
369
- public function setManager ($ pValue = '' )
373
+ public function setManager ($ value = '' )
370
374
{
371
- $ this ->manager = $ pValue ;
375
+ $ this ->manager = $ this ->setValue ($ value , '' );
376
+
372
377
return $ this ;
373
378
}
374
379
@@ -401,7 +406,7 @@ public function isCustomPropertySet($propertyName)
401
406
*/
402
407
public function getCustomPropertyValue ($ propertyName )
403
408
{
404
- if (isset ( $ this ->customProperties [ $ propertyName] )) {
409
+ if ($ this ->isCustomPropertySet ( $ propertyName )) {
405
410
return $ this ->customProperties [$ propertyName ]['value ' ];
406
411
}
407
412
@@ -415,7 +420,7 @@ public function getCustomPropertyValue($propertyName)
415
420
*/
416
421
public function getCustomPropertyType ($ propertyName )
417
422
{
418
- if (isset ( $ this ->customProperties [ $ propertyName] )) {
423
+ if ($ this ->isCustomPropertySet ( $ propertyName )) {
419
424
return $ this ->customProperties [$ propertyName ]['type ' ];
420
425
}
421
426
@@ -473,33 +478,49 @@ public function setCustomProperty($propertyName, $propertyValue = '', $propertyT
473
478
*/
474
479
public static function convertProperty ($ propertyValue , $ propertyType )
475
480
{
476
- $ typeGroups = array (
477
- 'empty ' => array ('empty ' ),
478
- 'null ' => array ('null ' ),
479
- 'int ' => array ('i1 ' , 'i2 ' , 'i4 ' , 'i8 ' , 'int ' ),
480
- 'abs ' => array ('ui1 ' , 'ui2 ' , 'ui4 ' , 'ui8 ' , 'uint ' ),
481
- 'float ' => array ('r4 ' , 'r8 ' , 'decimal ' ),
482
- 'date ' => array ('date ' , 'filetime ' ),
483
- 'bool ' => array ('bool ' ),
484
- );
485
- foreach ($ typeGroups as $ groupId => $ groupMembers ) {
486
- if (in_array ($ propertyType , $ groupMembers )) {
487
- if ($ groupId == 'null ' ) {
488
- return null ;
489
- } elseif ($ groupId == 'int ' ) {
490
- return (int ) $ propertyValue ;
491
- } elseif ($ groupId == 'abs ' ) {
492
- return abs ((int ) $ propertyValue );
493
- } elseif ($ groupId == 'float ' ) {
494
- return (float ) $ propertyValue ;
495
- } elseif ($ groupId == 'date ' ) {
496
- return strtotime ($ propertyValue );
497
- } elseif ($ groupId == 'bool ' ) {
498
- return ($ propertyValue == 'true ' ) ? true : false ;
499
- } else {
500
- return '' ;
501
- }
502
- }
481
+ switch ($ propertyType ) {
482
+ case 'empty ' : // Empty
483
+ return '' ;
484
+ case 'null ' : // Null
485
+ return null ;
486
+ case 'i1 ' : // 1-Byte Signed Integer
487
+ case 'i2 ' : // 2-Byte Signed Integer
488
+ case 'i4 ' : // 4-Byte Signed Integer
489
+ case 'i8 ' : // 8-Byte Signed Integer
490
+ case 'int ' : // Integer
491
+ return (int ) $ propertyValue ;
492
+ case 'ui1 ' : // 1-Byte Unsigned Integer
493
+ case 'ui2 ' : // 2-Byte Unsigned Integer
494
+ case 'ui4 ' : // 4-Byte Unsigned Integer
495
+ case 'ui8 ' : // 8-Byte Unsigned Integer
496
+ case 'uint ' : // Unsigned Integer
497
+ return abs ((int ) $ propertyValue );
498
+ case 'r4 ' : // 4-Byte Real Number
499
+ case 'r8 ' : // 8-Byte Real Number
500
+ case 'decimal ' : // Decimal
501
+ return (float ) $ propertyValue ;
502
+ case 'date ' : // Date and Time
503
+ case 'filetime ' : // File Time
504
+ return strtotime ($ propertyValue );
505
+ case 'bool ' : // Boolean
506
+ return ($ propertyValue == 'true ' ) ? true : false ;
507
+ case 'lpstr ' : // LPSTR
508
+ case 'lpwstr ' : // LPWSTR
509
+ case 'bstr ' : // Basic String
510
+ case 'cy ' : // Currency
511
+ case 'error ' : // Error Status Code
512
+ case 'vector ' : // Vector
513
+ case 'array ' : // Array
514
+ case 'blob ' : // Binary Blob
515
+ case 'oblob ' : // Binary Blob Object
516
+ case 'stream ' : // Binary Stream
517
+ case 'ostream ' : // Binary Stream Object
518
+ case 'storage ' : // Binary Storage
519
+ case 'ostorage ' : // Binary Storage Object
520
+ case 'vstream ' : // Binary Versioned Stream
521
+ case 'clsid ' : // Class ID
522
+ case 'cf ' : // Clipboard Data
523
+ return $ propertyValue ;
503
524
}
504
525
505
526
return $ propertyValue ;
@@ -528,4 +549,20 @@ public static function convertPropertyType($propertyType)
528
549
529
550
return self ::PROPERTY_TYPE_UNKNOWN ;
530
551
}
552
+
553
+ /**
554
+ * Set default for null and empty value
555
+ *
556
+ * @param mixed $value
557
+ * @param mixed $default
558
+ * @return mixed
559
+ */
560
+ private function setValue ($ value , $ default )
561
+ {
562
+ if (is_null ($ value ) || $ value == '' ) {
563
+ $ value = $ default ;
564
+ }
565
+
566
+ return $ value ;
567
+ }
531
568
}
0 commit comments