Theme.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
  3. class Theme
  4. {
  5. /**
  6. * Theme Name.
  7. *
  8. * @var string
  9. */
  10. private $themeName;
  11. /**
  12. * Colour Scheme Name.
  13. *
  14. * @var string
  15. */
  16. private $colourSchemeName;
  17. /**
  18. * Colour Map.
  19. *
  20. * @var array of string
  21. */
  22. private $colourMap;
  23. /**
  24. * Create a new Theme.
  25. *
  26. * @param mixed $themeName
  27. * @param mixed $colourSchemeName
  28. * @param mixed $colourMap
  29. */
  30. public function __construct($themeName, $colourSchemeName, $colourMap)
  31. {
  32. // Initialise values
  33. $this->themeName = $themeName;
  34. $this->colourSchemeName = $colourSchemeName;
  35. $this->colourMap = $colourMap;
  36. }
  37. /**
  38. * Get Theme Name.
  39. *
  40. * @return string
  41. */
  42. public function getThemeName()
  43. {
  44. return $this->themeName;
  45. }
  46. /**
  47. * Get colour Scheme Name.
  48. *
  49. * @return string
  50. */
  51. public function getColourSchemeName()
  52. {
  53. return $this->colourSchemeName;
  54. }
  55. /**
  56. * Get colour Map Value by Position.
  57. *
  58. * @param mixed $index
  59. *
  60. * @return string
  61. */
  62. public function getColourByIndex($index)
  63. {
  64. if (isset($this->colourMap[$index])) {
  65. return $this->colourMap[$index];
  66. }
  67. return null;
  68. }
  69. /**
  70. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  71. */
  72. public function __clone()
  73. {
  74. $vars = get_object_vars($this);
  75. foreach ($vars as $key => $value) {
  76. if ((is_object($value)) && ($key != '_parent')) {
  77. $this->$key = clone $value;
  78. } else {
  79. $this->$key = $value;
  80. }
  81. }
  82. }
  83. }