Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
FootnoteProperties
100.00% covered (success)
100.00%
28 / 28
100.00% covered (success)
100.00%
8 / 8
10
100.00% covered (success)
100.00%
1 / 1
 getPos
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPos
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
 getNumFmt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNumFmt
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getNumStart
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNumStart
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getNumRestart
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNumRestart
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
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
19namespace PhpOffice\PhpWord\ComplexType;
20
21use InvalidArgumentException;
22use PhpOffice\PhpWord\SimpleType\NumberFormat;
23
24/**
25 * Footnote properties.
26 *
27 * @see http://www.datypic.com/sc/ooxml/e-w_footnotePr-1.html
28 */
29final class FootnoteProperties
30{
31    const RESTART_NUMBER_CONTINUOUS = 'continuous';
32    const RESTART_NUMBER_EACH_SECTION = 'eachSect';
33    const RESTART_NUMBER_EACH_PAGE = 'eachPage';
34
35    const POSITION_PAGE_BOTTOM = 'pageBottom';
36    const POSITION_BENEATH_TEXT = 'beneathText';
37    const POSITION_SECTION_END = 'sectEnd';
38    const POSITION_DOC_END = 'docEnd';
39
40    /**
41     * Footnote Positioning Location.
42     *
43     * @var string
44     */
45    private $pos;
46
47    /**
48     * Footnote Numbering Format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat.
49     *
50     * @var string
51     */
52    private $numFmt;
53
54    /**
55     * Footnote and Endnote Numbering Starting Value.
56     *
57     * @var float
58     */
59    private $numStart;
60
61    /**
62     * Footnote and Endnote Numbering Restart Location.
63     *
64     * @var string
65     */
66    private $numRestart;
67
68    /**
69     * Get the Footnote Positioning Location.
70     *
71     * @return string
72     */
73    public function getPos()
74    {
75        return $this->pos;
76    }
77
78    /**
79     * Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd).
80     *
81     * @param string $pos
82     *
83     * @return self
84     */
85    public function setPos($pos)
86    {
87        $position = [
88            self::POSITION_PAGE_BOTTOM,
89            self::POSITION_BENEATH_TEXT,
90            self::POSITION_SECTION_END,
91            self::POSITION_DOC_END,
92        ];
93
94        if (in_array($pos, $position)) {
95            $this->pos = $pos;
96        } else {
97            throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
98        }
99
100        return $this;
101    }
102
103    /**
104     * Get the Footnote Numbering Format.
105     *
106     * @return string
107     */
108    public function getNumFmt()
109    {
110        return $this->numFmt;
111    }
112
113    /**
114     * Set the Footnote Numbering Format.
115     *
116     * @param string $numFmt One of NumberFormat
117     *
118     * @return self
119     */
120    public function setNumFmt($numFmt)
121    {
122        NumberFormat::validate($numFmt);
123        $this->numFmt = $numFmt;
124
125        return $this;
126    }
127
128    /**
129     * Get the Footnote Numbering Format.
130     *
131     * @return float
132     */
133    public function getNumStart()
134    {
135        return $this->numStart;
136    }
137
138    /**
139     * Set the Footnote Numbering Format.
140     *
141     * @param float $numStart
142     *
143     * @return self
144     */
145    public function setNumStart($numStart)
146    {
147        $this->numStart = $numStart;
148
149        return $this;
150    }
151
152    /**
153     * Get the Footnote and Endnote Numbering Starting Value.
154     *
155     * @return string
156     */
157    public function getNumRestart()
158    {
159        return $this->numRestart;
160    }
161
162    /**
163     * Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage).
164     *
165     * @param  string $numRestart
166     *
167     * @return self
168     */
169    public function setNumRestart($numRestart)
170    {
171        $restartNumbers = [
172            self::RESTART_NUMBER_CONTINUOUS,
173            self::RESTART_NUMBER_EACH_SECTION,
174            self::RESTART_NUMBER_EACH_PAGE,
175        ];
176
177        if (in_array($numRestart, $restartNumbers)) {
178            $this->numRestart = $numRestart;
179        } else {
180            throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
181        }
182
183        return $this;
184    }
185}