UtcOffset.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Sabre\VObject\Property;
  3. /**
  4. * UtcOffset property.
  5. *
  6. * This object encodes UTC-OFFSET values.
  7. *
  8. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  9. * @author Evert Pot (http://evertpot.com/)
  10. * @license http://sabre.io/license/ Modified BSD License
  11. */
  12. class UtcOffset extends Text
  13. {
  14. /**
  15. * In case this is a multi-value property. This string will be used as a
  16. * delimiter.
  17. *
  18. * @var string
  19. */
  20. public $delimiter = '';
  21. /**
  22. * Returns the type of value.
  23. *
  24. * This corresponds to the VALUE= parameter. Every property also has a
  25. * 'default' valueType.
  26. *
  27. * @return string
  28. */
  29. public function getValueType()
  30. {
  31. return 'UTC-OFFSET';
  32. }
  33. /**
  34. * Sets the JSON value, as it would appear in a jCard or jCal object.
  35. *
  36. * The value must always be an array.
  37. */
  38. public function setJsonValue(array $value)
  39. {
  40. $value = array_map(
  41. function ($value) {
  42. return str_replace(':', '', $value);
  43. },
  44. $value
  45. );
  46. parent::setJsonValue($value);
  47. }
  48. /**
  49. * Returns the value, in the format it should be encoded for JSON.
  50. *
  51. * This method must always return an array.
  52. *
  53. * @return array
  54. */
  55. public function getJsonValue()
  56. {
  57. return array_map(
  58. function ($value) {
  59. return substr($value, 0, -2).':'.
  60. substr($value, -2);
  61. },
  62. parent::getJsonValue()
  63. );
  64. }
  65. }