Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
ListItem | |
100.00% |
8 / 8 |
|
100.00% |
5 / 5 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
getStyle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTextObject | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDepth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
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 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | namespace PhpOffice\PhpWord\Element; |
19 | |
20 | use PhpOffice\PhpWord\Shared\Text as SharedText; |
21 | use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; |
22 | |
23 | /** |
24 | * List item element. |
25 | */ |
26 | class ListItem extends AbstractElement |
27 | { |
28 | /** |
29 | * Element style. |
30 | * |
31 | * @var ?\PhpOffice\PhpWord\Style\ListItem |
32 | */ |
33 | private $style; |
34 | |
35 | /** |
36 | * Text object. |
37 | * |
38 | * @var \PhpOffice\PhpWord\Element\Text |
39 | */ |
40 | private $textObject; |
41 | |
42 | /** |
43 | * Depth. |
44 | * |
45 | * @var int |
46 | */ |
47 | private $depth; |
48 | |
49 | /** |
50 | * Create a new ListItem. |
51 | * |
52 | * @param string $text |
53 | * @param int $depth |
54 | * @param mixed $fontStyle |
55 | * @param null|array|string $listStyle |
56 | * @param mixed $paragraphStyle |
57 | */ |
58 | public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) |
59 | { |
60 | $this->textObject = new Text(SharedText::toUTF8($text), $fontStyle, $paragraphStyle); |
61 | $this->depth = $depth; |
62 | |
63 | // Version >= 0.10.0 will pass numbering style name. Older version will use old method |
64 | if (null !== $listStyle && is_string($listStyle)) { |
65 | $this->style = new ListItemStyle($listStyle); // @codeCoverageIgnore |
66 | } else { |
67 | $this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true); |
68 | } |
69 | } |
70 | |
71 | /** |
72 | * Get style. |
73 | * |
74 | * @return ?\PhpOffice\PhpWord\Style\ListItem |
75 | */ |
76 | public function getStyle() |
77 | { |
78 | return $this->style; |
79 | } |
80 | |
81 | /** |
82 | * Get Text object. |
83 | * |
84 | * @return \PhpOffice\PhpWord\Element\Text |
85 | */ |
86 | public function getTextObject() |
87 | { |
88 | return $this->textObject; |
89 | } |
90 | |
91 | /** |
92 | * Get depth. |
93 | * |
94 | * @return int |
95 | */ |
96 | public function getDepth() |
97 | { |
98 | return $this->depth; |
99 | } |
100 | |
101 | /** |
102 | * Get text. |
103 | * |
104 | * @return string |
105 | * |
106 | * @since 0.11.0 |
107 | */ |
108 | public function getText() |
109 | { |
110 | return $this->textObject->getText(); |
111 | } |
112 | } |