TextElement.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * PHPExcel_RichText_TextElement
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. *
  19. * @category PHPExcel
  20. * @package PHPExcel_RichText
  21. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  22. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  23. * @version ##VERSION##, ##DATE##
  24. */
  25. class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
  26. {
  27. /**
  28. * Text
  29. *
  30. * @var string
  31. */
  32. private $text;
  33. /**
  34. * Create a new PHPExcel_RichText_TextElement instance
  35. *
  36. * @param string $pText Text
  37. */
  38. public function __construct($pText = '')
  39. {
  40. // Initialise variables
  41. $this->text = $pText;
  42. }
  43. /**
  44. * Get text
  45. *
  46. * @return string Text
  47. */
  48. public function getText()
  49. {
  50. return $this->text;
  51. }
  52. /**
  53. * Set text
  54. *
  55. * @param $pText string Text
  56. * @return PHPExcel_RichText_ITextElement
  57. */
  58. public function setText($pText = '')
  59. {
  60. $this->text = $pText;
  61. return $this;
  62. }
  63. /**
  64. * Get font
  65. *
  66. * @return PHPExcel_Style_Font
  67. */
  68. public function getFont()
  69. {
  70. return null;
  71. }
  72. /**
  73. * Get hash code
  74. *
  75. * @return string Hash code
  76. */
  77. public function getHashCode()
  78. {
  79. return md5(
  80. $this->text .
  81. __CLASS__
  82. );
  83. }
  84. /**
  85. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  86. */
  87. public function __clone()
  88. {
  89. $vars = get_object_vars($this);
  90. foreach ($vars as $key => $value) {
  91. if (is_object($value)) {
  92. $this->$key = clone $value;
  93. } else {
  94. $this->$key = $value;
  95. }
  96. }
  97. }
  98. }