Hyperlink.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Cell;
  3. class Hyperlink
  4. {
  5. /**
  6. * URL to link the cell to.
  7. *
  8. * @var string
  9. */
  10. private $url;
  11. /**
  12. * Tooltip to display on the hyperlink.
  13. *
  14. * @var string
  15. */
  16. private $tooltip;
  17. /**
  18. * Create a new Hyperlink.
  19. *
  20. * @param string $pUrl Url to link the cell to
  21. * @param string $pTooltip Tooltip to display on the hyperlink
  22. */
  23. public function __construct($pUrl = '', $pTooltip = '')
  24. {
  25. // Initialise member variables
  26. $this->url = $pUrl;
  27. $this->tooltip = $pTooltip;
  28. }
  29. /**
  30. * Get URL.
  31. *
  32. * @return string
  33. */
  34. public function getUrl()
  35. {
  36. return $this->url;
  37. }
  38. /**
  39. * Set URL.
  40. *
  41. * @param string $value
  42. *
  43. * @return Hyperlink
  44. */
  45. public function setUrl($value)
  46. {
  47. $this->url = $value;
  48. return $this;
  49. }
  50. /**
  51. * Get tooltip.
  52. *
  53. * @return string
  54. */
  55. public function getTooltip()
  56. {
  57. return $this->tooltip;
  58. }
  59. /**
  60. * Set tooltip.
  61. *
  62. * @param string $value
  63. *
  64. * @return Hyperlink
  65. */
  66. public function setTooltip($value)
  67. {
  68. $this->tooltip = $value;
  69. return $this;
  70. }
  71. /**
  72. * Is this hyperlink internal? (to another worksheet).
  73. *
  74. * @return bool
  75. */
  76. public function isInternal()
  77. {
  78. return strpos($this->url, 'sheet://') !== false;
  79. }
  80. /**
  81. * Get hash code.
  82. *
  83. * @return string Hash code
  84. */
  85. public function getHashCode()
  86. {
  87. return md5(
  88. $this->url .
  89. $this->tooltip .
  90. __CLASS__
  91. );
  92. }
  93. }