PageRenderTime 41ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/src/PhpWord/Style/Shading.php

https://github.com/cyrillkalita/PHPWord
PHP | 146 lines | 50 code | 15 blank | 81 comment | 0 complexity | 30c5d74a18ecd9e68a6c3b73beed0231 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Style;
  18. /**
  19. * Shading style
  20. *
  21. * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html
  22. * @since 0.10.0
  23. */
  24. class Shading extends AbstractStyle
  25. {
  26. /**
  27. * Pattern constants (partly)
  28. *
  29. * @const string
  30. * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
  31. */
  32. const PATTERN_CLEAR = 'clear'; // No pattern
  33. const PATTERN_SOLID = 'solid'; // 100% fill pattern
  34. const PATTERN_HSTRIPE = 'horzStripe'; // Horizontal stripe pattern
  35. const PATTERN_VSTRIPE = 'vertStripe'; // Vertical stripe pattern
  36. const PATTERN_DSTRIPE = 'diagStripe'; // Diagonal stripe pattern
  37. const PATTERN_HCROSS = 'horzCross'; // Horizontal cross pattern
  38. const PATTERN_DCROSS = 'diagCross'; // Diagonal cross pattern
  39. /**
  40. * Shading pattern
  41. *
  42. * @var string
  43. * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
  44. */
  45. private $pattern = self::PATTERN_CLEAR;
  46. /**
  47. * Shading pattern color
  48. *
  49. * @var string
  50. */
  51. private $color;
  52. /**
  53. * Shading background color
  54. *
  55. * @var string
  56. */
  57. private $fill;
  58. /**
  59. * Create a new instance
  60. *
  61. * @param array $style
  62. */
  63. public function __construct($style = array())
  64. {
  65. $this->setStyleByArray($style);
  66. }
  67. /**
  68. * Get pattern
  69. *
  70. * @return string
  71. */
  72. public function getPattern()
  73. {
  74. return $this->pattern;
  75. }
  76. /**
  77. * Set pattern
  78. *
  79. * @param string $value
  80. * @return self
  81. */
  82. public function setPattern($value = null)
  83. {
  84. $enum = array(
  85. self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE,
  86. self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS
  87. );
  88. $this->pattern = $this->setEnumVal($value, $enum, $this->pattern);
  89. return $this;
  90. }
  91. /**
  92. * Get color
  93. *
  94. * @return string
  95. */
  96. public function getColor()
  97. {
  98. return $this->color;
  99. }
  100. /**
  101. * Set pattern
  102. *
  103. * @param string $value
  104. * @return self
  105. */
  106. public function setColor($value = null)
  107. {
  108. $this->color = $value;
  109. return $this;
  110. }
  111. /**
  112. * Get fill
  113. *
  114. * @return string
  115. */
  116. public function getFill()
  117. {
  118. return $this->fill;
  119. }
  120. /**
  121. * Set fill
  122. *
  123. * @param string $value
  124. * @return self
  125. */
  126. public function setFill($value = null)
  127. {
  128. $this->fill = $value;
  129. return $this;
  130. }
  131. }