Run.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\RichText;
  3. use PhpOffice\PhpSpreadsheet\Style\Font;
  4. class Run extends TextElement implements ITextElement
  5. {
  6. /**
  7. * Font.
  8. *
  9. * @var Font
  10. */
  11. private $font;
  12. /**
  13. * Create a new Run instance.
  14. *
  15. * @param string $pText Text
  16. */
  17. public function __construct($pText = '')
  18. {
  19. parent::__construct($pText);
  20. // Initialise variables
  21. $this->font = new Font();
  22. }
  23. /**
  24. * Get font.
  25. *
  26. * @return Font
  27. */
  28. public function getFont()
  29. {
  30. return $this->font;
  31. }
  32. /**
  33. * Set font.
  34. *
  35. * @param Font $pFont Font
  36. *
  37. * @return ITextElement
  38. */
  39. public function setFont(Font $pFont = null)
  40. {
  41. $this->font = $pFont;
  42. return $this;
  43. }
  44. /**
  45. * Get hash code.
  46. *
  47. * @return string Hash code
  48. */
  49. public function getHashCode()
  50. {
  51. return md5(
  52. $this->getText() .
  53. $this->font->getHashCode() .
  54. __CLASS__
  55. );
  56. }
  57. }