Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Numbering | |
100.00% |
15 / 15 |
|
100.00% |
6 / 6 |
8 | |
100.00% |
1 / 1 |
| getNumId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setNumId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setType | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getLevels | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLevels | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
| 5 | * word processing documents. |
| 6 | * |
| 7 | * PHPWord is free software distributed under the terms of the GNU Lesser |
| 8 | * General Public License version 3 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * For the full copyright and license information, please read the LICENSE |
| 11 | * file that was distributed with this source code. For the full list of |
| 12 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 13 | * |
| 14 | * @see https://github.com/PHPOffice/PHPWord |
| 15 | * |
| 16 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 17 | */ |
| 18 | |
| 19 | namespace PhpOffice\PhpWord\Style; |
| 20 | |
| 21 | /** |
| 22 | * Numbering style. |
| 23 | * |
| 24 | * @see http://www.schemacentral.com/sc/ooxml/e-w_numbering.html |
| 25 | * @see http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html |
| 26 | * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html |
| 27 | * @since 0.10.0 |
| 28 | */ |
| 29 | class Numbering extends AbstractStyle |
| 30 | { |
| 31 | /** |
| 32 | * Numbering definition instance ID. |
| 33 | * |
| 34 | * @var int |
| 35 | * |
| 36 | * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html |
| 37 | */ |
| 38 | private $numId; |
| 39 | |
| 40 | /** |
| 41 | * Multilevel type singleLevel|multilevel|hybridMultilevel. |
| 42 | * |
| 43 | * @var string |
| 44 | * |
| 45 | * @see http://www.schemacentral.com/sc/ooxml/a-w_val-67.html |
| 46 | */ |
| 47 | private $type; |
| 48 | |
| 49 | /** |
| 50 | * Numbering levels. |
| 51 | * |
| 52 | * @var NumberingLevel[] |
| 53 | */ |
| 54 | private $levels = []; |
| 55 | |
| 56 | /** |
| 57 | * Get Id. |
| 58 | */ |
| 59 | public function getNumId(): ?int |
| 60 | { |
| 61 | return $this->numId; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Set Id. |
| 66 | */ |
| 67 | public function setNumId(int $value): self |
| 68 | { |
| 69 | $this->numId = $this->setIntVal($value, $this->numId); |
| 70 | |
| 71 | return $this; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Get multilevel type. |
| 76 | */ |
| 77 | public function getType(): ?string |
| 78 | { |
| 79 | return $this->type; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Set multilevel type. |
| 84 | */ |
| 85 | public function setType(string $value): self |
| 86 | { |
| 87 | $enum = ['singleLevel', 'multilevel', 'hybridMultilevel']; |
| 88 | $this->type = $this->setEnumVal($value, $enum, $this->type); |
| 89 | |
| 90 | return $this; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get levels. |
| 95 | * |
| 96 | * @return NumberingLevel[] |
| 97 | */ |
| 98 | public function getLevels(): array |
| 99 | { |
| 100 | return $this->levels; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Set multilevel type. |
| 105 | */ |
| 106 | public function setLevels(array $values): self |
| 107 | { |
| 108 | foreach ($values as $key => $value) { |
| 109 | $numberingLevel = new NumberingLevel(); |
| 110 | if (is_array($value)) { |
| 111 | $numberingLevel->setStyleByArray($value); |
| 112 | $numberingLevel->setLevel($key); |
| 113 | } |
| 114 | $this->levels[$key] = $numberingLevel; |
| 115 | } |
| 116 | |
| 117 | return $this; |
| 118 | } |
| 119 | } |