Border.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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. * @see https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2018 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 Top Style
  37. *
  38. * @var string
  39. */
  40. protected $borderTopStyle;
  41. /**
  42. * Border Left Size
  43. *
  44. * @var int|float
  45. */
  46. protected $borderLeftSize;
  47. /**
  48. * Border Left Color
  49. *
  50. * @var string
  51. */
  52. protected $borderLeftColor;
  53. /**
  54. * Border Left Style
  55. *
  56. * @var string
  57. */
  58. protected $borderLeftStyle;
  59. /**
  60. * Border Right Size
  61. *
  62. * @var int|float
  63. */
  64. protected $borderRightSize;
  65. /**
  66. * Border Right Color
  67. *
  68. * @var string
  69. */
  70. protected $borderRightColor;
  71. /**
  72. * Border Right Style
  73. *
  74. * @var string
  75. */
  76. protected $borderRightStyle;
  77. /**
  78. * Border Bottom Size
  79. *
  80. * @var int|float
  81. */
  82. protected $borderBottomSize;
  83. /**
  84. * Border Bottom Color
  85. *
  86. * @var string
  87. */
  88. protected $borderBottomColor;
  89. /**
  90. * Border Bottom Style
  91. *
  92. * @var string
  93. */
  94. protected $borderBottomStyle;
  95. /**
  96. * Get border size
  97. *
  98. * @return int[]
  99. */
  100. public function getBorderSize()
  101. {
  102. return array(
  103. $this->getBorderTopSize(),
  104. $this->getBorderLeftSize(),
  105. $this->getBorderRightSize(),
  106. $this->getBorderBottomSize(),
  107. );
  108. }
  109. /**
  110. * Set border size
  111. *
  112. * @param int|float $value
  113. * @return self
  114. */
  115. public function setBorderSize($value = null)
  116. {
  117. $this->setBorderTopSize($value);
  118. $this->setBorderLeftSize($value);
  119. $this->setBorderRightSize($value);
  120. $this->setBorderBottomSize($value);
  121. return $this;
  122. }
  123. /**
  124. * Get border color
  125. *
  126. * @return string[]
  127. */
  128. public function getBorderColor()
  129. {
  130. return array(
  131. $this->getBorderTopColor(),
  132. $this->getBorderLeftColor(),
  133. $this->getBorderRightColor(),
  134. $this->getBorderBottomColor(),
  135. );
  136. }
  137. /**
  138. * Set border color
  139. *
  140. * @param string $value
  141. * @return self
  142. */
  143. public function setBorderColor($value = null)
  144. {
  145. $this->setBorderTopColor($value);
  146. $this->setBorderLeftColor($value);
  147. $this->setBorderRightColor($value);
  148. $this->setBorderBottomColor($value);
  149. return $this;
  150. }
  151. /**
  152. * Get border style
  153. *
  154. * @return string[]
  155. */
  156. public function getBorderStyle()
  157. {
  158. return array(
  159. $this->getBorderTopStyle(),
  160. $this->getBorderLeftStyle(),
  161. $this->getBorderRightStyle(),
  162. $this->getBorderBottomStyle(),
  163. );
  164. }
  165. /**
  166. * Set border style
  167. *
  168. * @param string $value
  169. * @return self
  170. */
  171. public function setBorderStyle($value = null)
  172. {
  173. $this->setBorderTopStyle($value);
  174. $this->setBorderLeftStyle($value);
  175. $this->setBorderRightStyle($value);
  176. $this->setBorderBottomStyle($value);
  177. return $this;
  178. }
  179. /**
  180. * Get border top size
  181. *
  182. * @return int|float
  183. */
  184. public function getBorderTopSize()
  185. {
  186. return $this->borderTopSize;
  187. }
  188. /**
  189. * Set border top size
  190. *
  191. * @param int|float $value
  192. * @return self
  193. */
  194. public function setBorderTopSize($value = null)
  195. {
  196. $this->borderTopSize = $this->setNumericVal($value, $this->borderTopSize);
  197. return $this;
  198. }
  199. /**
  200. * Get border top color
  201. *
  202. * @return string
  203. */
  204. public function getBorderTopColor()
  205. {
  206. return $this->borderTopColor;
  207. }
  208. /**
  209. * Set border top color
  210. *
  211. * @param string $value
  212. * @return self
  213. */
  214. public function setBorderTopColor($value = null)
  215. {
  216. $this->borderTopColor = $value;
  217. return $this;
  218. }
  219. /**
  220. * Get border top style
  221. *
  222. * @return string
  223. */
  224. public function getBorderTopStyle()
  225. {
  226. return $this->borderTopStyle;
  227. }
  228. /**
  229. * Set border top Style
  230. *
  231. * @param string $value
  232. * @return self
  233. */
  234. public function setBorderTopStyle($value = null)
  235. {
  236. $this->borderTopStyle = $value;
  237. return $this;
  238. }
  239. /**
  240. * Get border left size
  241. *
  242. * @return int|float
  243. */
  244. public function getBorderLeftSize()
  245. {
  246. return $this->borderLeftSize;
  247. }
  248. /**
  249. * Set border left size
  250. *
  251. * @param int|float $value
  252. * @return self
  253. */
  254. public function setBorderLeftSize($value = null)
  255. {
  256. $this->borderLeftSize = $this->setNumericVal($value, $this->borderLeftSize);
  257. return $this;
  258. }
  259. /**
  260. * Get border left color
  261. *
  262. * @return string
  263. */
  264. public function getBorderLeftColor()
  265. {
  266. return $this->borderLeftColor;
  267. }
  268. /**
  269. * Set border left color
  270. *
  271. * @param string $value
  272. * @return self
  273. */
  274. public function setBorderLeftColor($value = null)
  275. {
  276. $this->borderLeftColor = $value;
  277. return $this;
  278. }
  279. /**
  280. * Get border left style
  281. *
  282. * @return string
  283. */
  284. public function getBorderLeftStyle()
  285. {
  286. return $this->borderLeftStyle;
  287. }
  288. /**
  289. * Set border left style
  290. *
  291. * @param string $value
  292. * @return self
  293. */
  294. public function setBorderLeftStyle($value = null)
  295. {
  296. $this->borderLeftStyle = $value;
  297. return $this;
  298. }
  299. /**
  300. * Get border right size
  301. *
  302. * @return int|float
  303. */
  304. public function getBorderRightSize()
  305. {
  306. return $this->borderRightSize;
  307. }
  308. /**
  309. * Set border right size
  310. *
  311. * @param int|float $value
  312. * @return self
  313. */
  314. public function setBorderRightSize($value = null)
  315. {
  316. $this->borderRightSize = $this->setNumericVal($value, $this->borderRightSize);
  317. return $this;
  318. }
  319. /**
  320. * Get border right color
  321. *
  322. * @return string
  323. */
  324. public function getBorderRightColor()
  325. {
  326. return $this->borderRightColor;
  327. }
  328. /**
  329. * Set border right color
  330. *
  331. * @param string $value
  332. * @return self
  333. */
  334. public function setBorderRightColor($value = null)
  335. {
  336. $this->borderRightColor = $value;
  337. return $this;
  338. }
  339. /**
  340. * Get border right style
  341. *
  342. * @return string
  343. */
  344. public function getBorderRightStyle()
  345. {
  346. return $this->borderRightStyle;
  347. }
  348. /**
  349. * Set border right style
  350. *
  351. * @param string $value
  352. * @return self
  353. */
  354. public function setBorderRightStyle($value = null)
  355. {
  356. $this->borderRightStyle = $value;
  357. return $this;
  358. }
  359. /**
  360. * Get border bottom size
  361. *
  362. * @return int|float
  363. */
  364. public function getBorderBottomSize()
  365. {
  366. return $this->borderBottomSize;
  367. }
  368. /**
  369. * Set border bottom size
  370. *
  371. * @param int|float $value
  372. * @return self
  373. */
  374. public function setBorderBottomSize($value = null)
  375. {
  376. $this->borderBottomSize = $this->setNumericVal($value, $this->borderBottomSize);
  377. return $this;
  378. }
  379. /**
  380. * Get border bottom color
  381. *
  382. * @return string
  383. */
  384. public function getBorderBottomColor()
  385. {
  386. return $this->borderBottomColor;
  387. }
  388. /**
  389. * Set border bottom color
  390. *
  391. * @param string $value
  392. * @return self
  393. */
  394. public function setBorderBottomColor($value = null)
  395. {
  396. $this->borderBottomColor = $value;
  397. return $this;
  398. }
  399. /**
  400. * Get border bottom style
  401. *
  402. * @return string
  403. */
  404. public function getBorderBottomStyle()
  405. {
  406. return $this->borderBottomStyle;
  407. }
  408. /**
  409. * Set border bottom style
  410. *
  411. * @param string $value
  412. * @return self
  413. */
  414. public function setBorderBottomStyle($value = null)
  415. {
  416. $this->borderBottomStyle = $value;
  417. return $this;
  418. }
  419. /**
  420. * Check if any of the border is not null
  421. *
  422. * @return bool
  423. */
  424. public function hasBorder()
  425. {
  426. $borders = $this->getBorderSize();
  427. return $borders !== array_filter($borders, 'is_null');
  428. }
  429. }