CalAddress.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Sabre\VObject\Property\ICalendar;
  3. use Sabre\VObject\Property\Text;
  4. /**
  5. * CalAddress property.
  6. *
  7. * This object encodes CAL-ADDRESS values, as defined in rfc5545
  8. *
  9. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  10. * @author Evert Pot (http://evertpot.com/)
  11. * @license http://sabre.io/license/ Modified BSD License
  12. */
  13. class CalAddress extends Text
  14. {
  15. /**
  16. * In case this is a multi-value property. This string will be used as a
  17. * delimiter.
  18. *
  19. * @var string
  20. */
  21. public $delimiter = '';
  22. /**
  23. * Returns the type of value.
  24. *
  25. * This corresponds to the VALUE= parameter. Every property also has a
  26. * 'default' valueType.
  27. *
  28. * @return string
  29. */
  30. public function getValueType()
  31. {
  32. return 'CAL-ADDRESS';
  33. }
  34. /**
  35. * This returns a normalized form of the value.
  36. *
  37. * This is primarily used right now to turn mixed-cased schemes in user
  38. * uris to lower-case.
  39. *
  40. * Evolution in particular tends to encode mailto: as MAILTO:.
  41. *
  42. * @return string
  43. */
  44. public function getNormalizedValue()
  45. {
  46. $input = $this->getValue();
  47. if (!strpos($input, ':')) {
  48. return $input;
  49. }
  50. list($schema, $everythingElse) = explode(':', $input, 2);
  51. $schema = strtolower($schema);
  52. if ('mailto' === $schema) {
  53. $everythingElse = strtolower($everythingElse);
  54. }
  55. return $schema.':'.$everythingElse;
  56. }
  57. }