Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
80.00% |
4 / 5 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
AbstractPart | |
80.00% |
4 / 5 |
|
66.67% |
2 / 3 |
4.13 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
write | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
setParentWriter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getParentWriter | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 |
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\Part; |
20 | |
21 | use PhpOffice\PhpWord\Escaper\Rtf; |
22 | use PhpOffice\PhpWord\Exception\Exception; |
23 | use PhpOffice\PhpWord\Writer\AbstractWriter; |
24 | |
25 | /** |
26 | * @since 0.11.0 |
27 | */ |
28 | abstract class AbstractPart |
29 | { |
30 | /** |
31 | * @var \PhpOffice\PhpWord\Writer\RTF |
32 | */ |
33 | private $parentWriter; |
34 | |
35 | /** |
36 | * @var \PhpOffice\PhpWord\Escaper\EscaperInterface |
37 | */ |
38 | protected $escaper; |
39 | |
40 | public function __construct() |
41 | { |
42 | $this->escaper = new Rtf(); |
43 | } |
44 | |
45 | /** |
46 | * @return string |
47 | */ |
48 | abstract public function write(); |
49 | |
50 | /** |
51 | * @param \PhpOffice\PhpWord\Writer\RTF $writer |
52 | */ |
53 | public function setParentWriter(?AbstractWriter $writer = null): void |
54 | { |
55 | $this->parentWriter = $writer; |
56 | } |
57 | |
58 | /** |
59 | * @return \PhpOffice\PhpWord\Writer\RTF |
60 | */ |
61 | public function getParentWriter() |
62 | { |
63 | if ($this->parentWriter !== null) { |
64 | return $this->parentWriter; |
65 | } |
66 | |
67 | throw new Exception('No parent WriterInterface assigned.'); |
68 | } |
69 | } |