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