Row.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\Element;
  18. use PhpOffice\PhpWord\Style\Row as RowStyle;
  19. /**
  20. * Table row element
  21. *
  22. * @since 0.8.0
  23. */
  24. class Row extends AbstractElement
  25. {
  26. /**
  27. * Row height
  28. *
  29. * @var int
  30. */
  31. private $height = null;
  32. /**
  33. * Row style
  34. *
  35. * @var \PhpOffice\PhpWord\Style\Row
  36. */
  37. private $style;
  38. /**
  39. * Row cells
  40. *
  41. * @var \PhpOffice\PhpWord\Element\Cell[]
  42. */
  43. private $cells = array();
  44. /**
  45. * Create a new table row
  46. *
  47. * @param int $height
  48. * @param mixed $style
  49. */
  50. public function __construct($height = null, $style = null)
  51. {
  52. $this->height = $height;
  53. $this->style = $this->setNewStyle(new RowStyle(), $style, true);
  54. }
  55. /**
  56. * Add a cell
  57. *
  58. * @param int $width
  59. * @param mixed $style
  60. * @return \PhpOffice\PhpWord\Element\Cell
  61. */
  62. public function addCell($width = null, $style = null)
  63. {
  64. $cell = new Cell($width, $style);
  65. $cell->setParentContainer($this);
  66. $this->cells[] = $cell;
  67. return $cell;
  68. }
  69. /**
  70. * Get all cells
  71. *
  72. * @return \PhpOffice\PhpWord\Element\Cell[]
  73. */
  74. public function getCells()
  75. {
  76. return $this->cells;
  77. }
  78. /**
  79. * Get row style
  80. *
  81. * @return \PhpOffice\PhpWord\Style\Row
  82. */
  83. public function getStyle()
  84. {
  85. return $this->style;
  86. }
  87. /**
  88. * Get row height
  89. *
  90. * @return int
  91. */
  92. public function getHeight()
  93. {
  94. return $this->height;
  95. }
  96. }