Nessuna descrizione

Border.php 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. * Border style
  20. */
  21. class Border extends AbstractStyle
  22. {
  23. /**
  24. * Border Top Size
  25. *
  26. * @var int|float
  27. */
  28. protected $borderTopSize;
  29. /**
  30. * Border Top Color
  31. *
  32. * @var string
  33. */
  34. protected $borderTopColor;
  35. /**
  36. * Border Left Size
  37. *
  38. * @var int|float
  39. */
  40. protected $borderLeftSize;
  41. /**
  42. * Border Left Color
  43. *
  44. * @var string
  45. */
  46. protected $borderLeftColor;
  47. /**
  48. * Border Right Size
  49. *
  50. * @var int|float
  51. */
  52. protected $borderRightSize;
  53. /**
  54. * Border Right Color
  55. *
  56. * @var string
  57. */
  58. protected $borderRightColor;
  59. /**
  60. * Border Bottom Size
  61. *
  62. * @var int|float
  63. */
  64. protected $borderBottomSize;
  65. /**
  66. * Border Bottom Color
  67. *
  68. * @var string
  69. */
  70. protected $borderBottomColor;
  71. /**
  72. * Get border size
  73. *
  74. * @return integer[]
  75. */
  76. public function getBorderSize()
  77. {
  78. return array(
  79. $this->getBorderTopSize(),
  80. $this->getBorderLeftSize(),
  81. $this->getBorderRightSize(),
  82. $this->getBorderBottomSize(),
  83. );
  84. }
  85. /**
  86. * Set border size
  87. *
  88. * @param int|float $value
  89. * @return self
  90. */
  91. public function setBorderSize($value = null)
  92. {
  93. $this->setBorderTopSize($value);
  94. $this->setBorderLeftSize($value);
  95. $this->setBorderRightSize($value);
  96. $this->setBorderBottomSize($value);
  97. return $this;
  98. }
  99. /**
  100. * Get border color
  101. *
  102. * @return string[]
  103. */
  104. public function getBorderColor()
  105. {
  106. return array(
  107. $this->getBorderTopColor(),
  108. $this->getBorderLeftColor(),
  109. $this->getBorderRightColor(),
  110. $this->getBorderBottomColor(),
  111. );
  112. }
  113. /**
  114. * Set border color
  115. *
  116. * @param string $value
  117. * @return self
  118. */
  119. public function setBorderColor($value = null)
  120. {
  121. $this->setBorderTopColor($value);
  122. $this->setBorderLeftColor($value);
  123. $this->setBorderRightColor($value);
  124. $this->setBorderBottomColor($value);
  125. return $this;
  126. }
  127. /**
  128. * Get border top size
  129. *
  130. * @return int|float
  131. */
  132. public function getBorderTopSize()
  133. {
  134. return $this->borderTopSize;
  135. }
  136. /**
  137. * Set border top size
  138. *
  139. * @param int|float $value
  140. * @return self
  141. */
  142. public function setBorderTopSize($value = null)
  143. {
  144. $this->borderTopSize = $this->setNumericVal($value, $this->borderTopSize);
  145. return $this;
  146. }
  147. /**
  148. * Get border top color
  149. *
  150. * @return string
  151. */
  152. public function getBorderTopColor()
  153. {
  154. return $this->borderTopColor;
  155. }
  156. /**
  157. * Set border top color
  158. *
  159. * @param string $value
  160. * @return self
  161. */
  162. public function setBorderTopColor($value = null)
  163. {
  164. $this->borderTopColor = $value;
  165. return $this;
  166. }
  167. /**
  168. * Get border left size
  169. *
  170. * @return int|float
  171. */
  172. public function getBorderLeftSize()
  173. {
  174. return $this->borderLeftSize;
  175. }
  176. /**
  177. * Set border left size
  178. *
  179. * @param int|float $value
  180. * @return self
  181. */
  182. public function setBorderLeftSize($value = null)
  183. {
  184. $this->borderLeftSize = $this->setNumericVal($value, $this->borderLeftSize);
  185. return $this;
  186. }
  187. /**
  188. * Get border left color
  189. *
  190. * @return string
  191. */
  192. public function getBorderLeftColor()
  193. {
  194. return $this->borderLeftColor;
  195. }
  196. /**
  197. * Set border left color
  198. *
  199. * @param string $value
  200. * @return self
  201. */
  202. public function setBorderLeftColor($value = null)
  203. {
  204. $this->borderLeftColor = $value;
  205. return $this;
  206. }
  207. /**
  208. * Get border right size
  209. *
  210. * @return int|float
  211. */
  212. public function getBorderRightSize()
  213. {
  214. return $this->borderRightSize;
  215. }
  216. /**
  217. * Set border right size
  218. *
  219. * @param int|float $value
  220. * @return self
  221. */
  222. public function setBorderRightSize($value = null)
  223. {
  224. $this->borderRightSize = $this->setNumericVal($value, $this->borderRightSize);
  225. return $this;
  226. }
  227. /**
  228. * Get border right color
  229. *
  230. * @return string
  231. */
  232. public function getBorderRightColor()
  233. {
  234. return $this->borderRightColor;
  235. }
  236. /**
  237. * Set border right color
  238. *
  239. * @param string $value
  240. * @return self
  241. */
  242. public function setBorderRightColor($value = null)
  243. {
  244. $this->borderRightColor = $value;
  245. return $this;
  246. }
  247. /**
  248. * Get border bottom size
  249. *
  250. * @return int|float
  251. */
  252. public function getBorderBottomSize()
  253. {
  254. return $this->borderBottomSize;
  255. }
  256. /**
  257. * Set border bottom size
  258. *
  259. * @param int|float $value
  260. * @return self
  261. */
  262. public function setBorderBottomSize($value = null)
  263. {
  264. $this->borderBottomSize = $this->setNumericVal($value, $this->borderBottomSize);
  265. return $this;
  266. }
  267. /**
  268. * Get border bottom color
  269. *
  270. * @return string
  271. */
  272. public function getBorderBottomColor()
  273. {
  274. return $this->borderBottomColor;
  275. }
  276. /**
  277. * Set border bottom color
  278. *
  279. * @param string $value
  280. * @return self
  281. */
  282. public function setBorderBottomColor($value = null)
  283. {
  284. $this->borderBottomColor = $value;
  285. return $this;
  286. }
  287. /**
  288. * Check if any of the border is not null
  289. *
  290. * @return bool
  291. */
  292. public function hasBorder()
  293. {
  294. $borders = $this->getBorderSize();
  295. return $borders !== array_filter($borders, 'is_null');
  296. }
  297. }