PageRenderTime 35ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/src/PhpWord/Style/Numbering.php

https://github.com/cyrillkalita/PHPWord
PHP | 131 lines | 45 code | 13 blank | 73 comment | 2 complexity | 6f9dfa54ed4f8837f934a7b5a00172d9 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
  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. * Numbering style
  20. *
  21. * @link http://www.schemacentral.com/sc/ooxml/e-w_numbering.html
  22. * @link http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html
  23. * @link http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
  24. * @since 0.10.0
  25. */
  26. class Numbering extends AbstractStyle
  27. {
  28. /**
  29. * Numbering definition instance ID
  30. *
  31. * @var int
  32. * @link http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
  33. */
  34. private $numId;
  35. /**
  36. * Multilevel type singleLevel|multilevel|hybridMultilevel
  37. *
  38. * @var string
  39. * @link http://www.schemacentral.com/sc/ooxml/a-w_val-67.html
  40. */
  41. private $type;
  42. /**
  43. * Numbering levels
  44. *
  45. * @var NumberingLevel[]
  46. */
  47. private $levels = array();
  48. /**
  49. * Get Id
  50. *
  51. * @return integer
  52. */
  53. public function getNumId()
  54. {
  55. return $this->numId;
  56. }
  57. /**
  58. * Set Id
  59. *
  60. * @param integer $value
  61. * @return self
  62. */
  63. public function setNumId($value)
  64. {
  65. $this->numId = $this->setIntVal($value, $this->numId);
  66. return $this;
  67. }
  68. /**
  69. * Get multilevel type
  70. *
  71. * @return string
  72. */
  73. public function getType()
  74. {
  75. return $this->type;
  76. }
  77. /**
  78. * Set multilevel type
  79. *
  80. * @param string $value
  81. * @return self
  82. */
  83. public function setType($value)
  84. {
  85. $enum = array('singleLevel', 'multilevel', 'hybridMultilevel');
  86. $this->type = $this->setEnumVal($value, $enum, $this->type);
  87. return $this;
  88. }
  89. /**
  90. * Get levels
  91. *
  92. * @return NumberingLevel[]
  93. */
  94. public function getLevels()
  95. {
  96. return $this->levels;
  97. }
  98. /**
  99. * Set multilevel type
  100. *
  101. * @param array $values
  102. * @return self
  103. */
  104. public function setLevels($values)
  105. {
  106. if (is_array($values)) {
  107. foreach ($values as $key => $value) {
  108. $numberingLevel = new NumberingLevel();
  109. if (is_array($value)) {
  110. $numberingLevel->setStyleByArray($value);
  111. $numberingLevel->setLevel($key);
  112. }
  113. $this->levels[$key] = $numberingLevel;
  114. }
  115. }
  116. return $this;
  117. }
  118. }