Completed
Push — develop ( 3560f1...5fce89 )
by Adrien
21:58 queued 15:06
created

WriterPart::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx;
4
5
/**
6
 * Copyright (c) 2006 - 2015 PhpSpreadsheet.
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 *
22
 * @category   PhpSpreadsheet
23
 *
24
 * @copyright  Copyright (c) 2006 - 2015 PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet)
25
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
26
 */
27
abstract class WriterPart
28
{
29
    /**
30
     * Parent IWriter object.
31
     *
32
     * @var \PhpOffice\PhpSpreadsheet\Writer\IWriter
33
     */
34
    private $parentWriter;
35
36
    /**
37
     * Set parent IWriter object.
38
     *
39
     * @param \PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter
40
     *
41
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
42
     */
43 2
    public function setParentWriter(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter = null)
44
    {
45 2
        $this->parentWriter = $pWriter;
46 2
    }
47
48
    /**
49
     * Get parent IWriter object.
50
     *
51
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
52
     *
53
     * @return \PhpOffice\PhpSpreadsheet\Writer\IWriter
54
     */
55 58
    public function getParentWriter()
56
    {
57 58
        if (!is_null($this->parentWriter)) {
58 58
            return $this->parentWriter;
59
        }
60
        throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('No parent \\PhpOffice\\PhpSpreadsheet\\Writer\\IWriter assigned.');
61
    }
62
63
    /**
64
     * Set parent IWriter object.
65
     *
66
     * @param \PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter
67
     *
68
     * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
69
     */
70 58
    public function __construct(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter = null)
71
    {
72 58
        if (!is_null($pWriter)) {
73 58
            $this->parentWriter = $pWriter;
74
        }
75 58
    }
76
}
77