ListItemRun.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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\ListItem as ListItemStyle;
  19. /**
  20. * List item element
  21. */
  22. class ListItemRun extends TextRun
  23. {
  24. /**
  25. * @var string Container type
  26. */
  27. protected $container = 'ListItemRun';
  28. /**
  29. * ListItem Style
  30. *
  31. * @var \PhpOffice\PhpWord\Style\ListItem
  32. */
  33. private $style;
  34. /**
  35. * ListItem Depth
  36. *
  37. * @var int
  38. */
  39. private $depth;
  40. /**
  41. * Create a new ListItem
  42. *
  43. * @param int $depth
  44. * @param array|string|null $listStyle
  45. * @param mixed $paragraphStyle
  46. */
  47. public function __construct($depth = 0, $listStyle = null, $paragraphStyle = null)
  48. {
  49. $this->depth = $depth;
  50. // Version >= 0.10.0 will pass numbering style name. Older version will use old method
  51. if (!is_null($listStyle) && is_string($listStyle)) {
  52. $this->style = new ListItemStyle($listStyle);
  53. } else {
  54. $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
  55. }
  56. parent::__construct($paragraphStyle);
  57. }
  58. /**
  59. * Get ListItem style.
  60. *
  61. * @return \PhpOffice\PhpWord\Style\ListItem
  62. */
  63. public function getStyle()
  64. {
  65. return $this->style;
  66. }
  67. /**
  68. * Get ListItem depth.
  69. *
  70. * @return int
  71. */
  72. public function getDepth()
  73. {
  74. return $this->depth;
  75. }
  76. }