Run.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
  8. {
  9. /**
  10. * Font
  11. *
  12. * @var PHPExcel_Style_Font
  13. */
  14. private $font;
  15. /**
  16. * Create a new PHPExcel_RichText_Run instance
  17. *
  18. * @param string $pText Text
  19. */
  20. public function __construct($pText = '')
  21. {
  22. // Initialise variables
  23. $this->setText($pText);
  24. $this->font = new PHPExcel_Style_Font();
  25. }
  26. /**
  27. * Get font
  28. *
  29. * @return PHPExcel_Style_Font
  30. */
  31. public function getFont()
  32. {
  33. return $this->font;
  34. }
  35. /**
  36. * Set font
  37. *
  38. * @param PHPExcel_Style_Font $pFont Font
  39. * @throws PHPExcel_Exception
  40. * @return PHPExcel_RichText_ITextElement
  41. */
  42. public function setFont(PHPExcel_Style_Font $pFont = null)
  43. {
  44. $this->font = $pFont;
  45. return $this;
  46. }
  47. /**
  48. * Get hash code
  49. *
  50. * @return string Hash code
  51. */
  52. public function getHashCode()
  53. {
  54. return md5(
  55. $this->getText() .
  56. $this->font->getHashCode() .
  57. __CLASS__
  58. );
  59. }
  60. /**
  61. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  62. */
  63. public function __clone()
  64. {
  65. $vars = get_object_vars($this);
  66. foreach ($vars as $key => $value) {
  67. if (is_object($value)) {
  68. $this->$key = clone $value;
  69. } else {
  70. $this->$key = $value;
  71. }
  72. }
  73. }
  74. }