Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractPart
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 write
n/a
0 / 0
n/a
0 / 0
0
 setParentWriter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getParentWriter
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
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
18namespace PhpOffice\PhpWord\Writer\HTML\Part;
19
20use PhpOffice\PhpWord\Exception\Exception;
21use PhpOffice\PhpWord\Writer\HTML;
22
23/**
24 * @since 0.11.0
25 */
26abstract class AbstractPart
27{
28    /**
29     * @var ?HTML
30     */
31    private $parentWriter;
32
33    /**
34     * @return string
35     */
36    abstract public function write();
37
38    public function setParentWriter(?HTML $writer = null): void
39    {
40        $this->parentWriter = $writer;
41    }
42
43    /**
44     * @return HTML
45     */
46    public function getParentWriter()
47    {
48        if ($this->parentWriter !== null) {
49            return $this->parentWriter;
50        }
51
52        throw new Exception('No parent WriterInterface assigned.');
53    }
54}