ListItemRun.php 2.1 KB

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