Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
AbstractStyle | |
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
8 | |
100.00% |
1 / 1 |
write | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setParentWriter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getParentWriter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getStyle | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
getValueIf | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 |
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\Writer\RTF\Style; |
19 | |
20 | use PhpOffice\PhpWord\Style\AbstractStyle as StyleAbstract; |
21 | use PhpOffice\PhpWord\Writer\RTF; |
22 | |
23 | /** |
24 | * Abstract RTF style writer. |
25 | * |
26 | * @since 0.11.0 |
27 | */ |
28 | abstract class AbstractStyle |
29 | { |
30 | /** |
31 | * Parent writer. |
32 | * |
33 | * @var RTF |
34 | */ |
35 | private $parentWriter; |
36 | |
37 | /** |
38 | * Style. |
39 | * |
40 | * @var null|array|StyleAbstract |
41 | */ |
42 | private $style; |
43 | |
44 | /** |
45 | * Write style. |
46 | * |
47 | * @return mixed |
48 | */ |
49 | abstract public function write(); |
50 | |
51 | /** |
52 | * Create new instance. |
53 | * |
54 | * @param array|StyleAbstract $style |
55 | */ |
56 | public function __construct($style = null) |
57 | { |
58 | $this->style = $style; |
59 | } |
60 | |
61 | /** |
62 | * Set parent writer. |
63 | * |
64 | * @param RTF $writer |
65 | */ |
66 | public function setParentWriter($writer): void |
67 | { |
68 | $this->parentWriter = $writer; |
69 | } |
70 | |
71 | /** |
72 | * Get parent writer. |
73 | * |
74 | * @return RTF |
75 | */ |
76 | public function getParentWriter() |
77 | { |
78 | return $this->parentWriter; |
79 | } |
80 | |
81 | /** |
82 | * Get style. |
83 | * |
84 | * @return null|array|string|StyleAbstract |
85 | */ |
86 | public function getStyle() |
87 | { |
88 | if (!$this->style instanceof StyleAbstract && !is_array($this->style)) { |
89 | return ''; |
90 | } |
91 | |
92 | return $this->style; |
93 | } |
94 | |
95 | /** |
96 | * Get value if ... |
97 | * |
98 | * @param null|bool $condition |
99 | * @param string $value |
100 | * |
101 | * @return string |
102 | */ |
103 | protected function getValueIf($condition, $value) |
104 | { |
105 | return $condition == true ? $value : ''; |
106 | } |
107 | } |