Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
56 / 56
100.00% covered (success)
100.00%
21 / 21
CRAP
100.00% covered (success)
100.00%
1 / 1
TablePosition
100.00% covered (success)
100.00%
56 / 56
100.00% covered (success)
100.00%
21 / 21
21
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLeftFromText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLeftFromText
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getRightFromText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRightFromText
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTopFromText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTopFromText
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getBottomFromText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBottomFromText
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getVertAnchor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setVertAnchor
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getHorzAnchor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHorzAnchor
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getTblpXSpec
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTblpXSpec
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 getTblpX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTblpX
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTblpYSpec
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTblpYSpec
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
 getTblpY
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTblpY
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
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\Style;
19
20/**
21 * TablePosition style.
22 *
23 * @see http://www.datypic.com/sc/ooxml/e-w_tblpPr-1.html
24 */
25class TablePosition extends AbstractStyle
26{
27    /**
28     * Vertical anchor constants.
29     *
30     * @const string
31     *
32     * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
33     */
34    const VANCHOR_TEXT = 'text'; // Relative to vertical text extents
35    const VANCHOR_MARGIN = 'margin'; // Relative to margin
36    const VANCHOR_PAGE = 'page'; // Relative to page
37
38    /**
39     * Horizontal anchor constants.
40     *
41     * @const string
42     *
43     * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
44     */
45    const HANCHOR_TEXT = 'text'; // Relative to text extents
46    const HANCHOR_MARGIN = 'margin'; // Relative to margin
47    const HANCHOR_PAGE = 'page'; // Relative to page
48
49    /**
50     * Horizontal alignment constants.
51     *
52     * @const string
53     *
54     * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
55     */
56    const XALIGN_LEFT = 'left'; // Left aligned horizontally
57    const XALIGN_CENTER = 'center'; // Centered horizontally
58    const XALIGN_RIGHT = 'right'; // Right aligned horizontally
59    const XALIGN_INSIDE = 'inside'; // Inside
60    const XALIGN_OUTSIDE = 'outside'; // Outside
61
62    /**
63     * Vertical alignment constants.
64     *
65     * @const string
66     *
67     * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
68     */
69    const YALIGN_INLINE = 'inline'; // In line with text
70    const YALIGN_TOP = 'top'; // Top
71    const YALIGN_CENTER = 'center'; // Centered vertically
72    const YALIGN_BOTTOM = 'bottom'; // Bottom
73    const YALIGN_INSIDE = 'inside'; // Inside Anchor Extents
74    const YALIGN_OUTSIDE = 'outside'; // Centered vertically
75
76    /**
77     * Distance from left of table to text.
78     *
79     * @var int
80     */
81    private $leftFromText;
82
83    /**
84     * Distance from right of table to text.
85     *
86     * @var int
87     */
88    private $rightFromText;
89
90    /**
91     * Distance from top of table to text.
92     *
93     * @var int
94     */
95    private $topFromText;
96
97    /**
98     * Distance from bottom of table to text.
99     *
100     * @var int
101     */
102    private $bottomFromText;
103
104    /**
105     * Table vertical anchor.
106     *
107     * @var string
108     *
109     * @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
110     */
111    private $vertAnchor;
112
113    /**
114     * Table horizontal anchor.
115     *
116     * @var string
117     *
118     * @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
119     */
120    private $horzAnchor;
121
122    /**
123     * Relative horizontal alignment from anchor.
124     *
125     * @var string
126     *
127     * @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
128     */
129    private $tblpXSpec;
130
131    /**
132     * Absolute horizontal distance from anchor.
133     *
134     * @var int
135     */
136    private $tblpX;
137
138    /**
139     * Relative vertical alignment from anchor.
140     *
141     * @var string
142     *
143     * @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
144     */
145    private $tblpYSpec;
146
147    /**
148     * Absolute vertical distance from anchor.
149     *
150     * @var int
151     */
152    private $tblpY;
153
154    /**
155     * Create a new instance.
156     *
157     * @param array $style
158     */
159    public function __construct($style = [])
160    {
161        $this->setStyleByArray($style);
162    }
163
164    /**
165     * Get distance from left of table to text.
166     *
167     * @return int
168     */
169    public function getLeftFromText()
170    {
171        return $this->leftFromText;
172    }
173
174    /**
175     * Set distance from left of table to text.
176     *
177     * @param int $value
178     *
179     * @return self
180     */
181    public function setLeftFromText($value = null)
182    {
183        $this->leftFromText = $this->setNumericVal($value, $this->leftFromText);
184
185        return $this;
186    }
187
188    /**
189     * Get distance from right of table to text.
190     *
191     * @return int
192     */
193    public function getRightFromText()
194    {
195        return $this->rightFromText;
196    }
197
198    /**
199     * Set distance from right of table to text.
200     *
201     * @param int $value
202     *
203     * @return self
204     */
205    public function setRightFromText($value = null)
206    {
207        $this->rightFromText = $this->setNumericVal($value, $this->rightFromText);
208
209        return $this;
210    }
211
212    /**
213     * Get distance from top of table to text.
214     *
215     * @return int
216     */
217    public function getTopFromText()
218    {
219        return $this->topFromText;
220    }
221
222    /**
223     * Set distance from top of table to text.
224     *
225     * @param int $value
226     *
227     * @return self
228     */
229    public function setTopFromText($value = null)
230    {
231        $this->topFromText = $this->setNumericVal($value, $this->topFromText);
232
233        return $this;
234    }
235
236    /**
237     * Get distance from bottom of table to text.
238     *
239     * @return int
240     */
241    public function getBottomFromText()
242    {
243        return $this->bottomFromText;
244    }
245
246    /**
247     * Set distance from bottom of table to text.
248     *
249     * @param int $value
250     *
251     * @return self
252     */
253    public function setBottomFromText($value = null)
254    {
255        $this->bottomFromText = $this->setNumericVal($value, $this->bottomFromText);
256
257        return $this;
258    }
259
260    /**
261     * Get table vertical anchor.
262     *
263     * @return string
264     */
265    public function getVertAnchor()
266    {
267        return $this->vertAnchor;
268    }
269
270    /**
271     * Set table vertical anchor.
272     *
273     * @param string $value
274     *
275     * @return self
276     */
277    public function setVertAnchor($value = null)
278    {
279        $enum = [
280            self::VANCHOR_TEXT,
281            self::VANCHOR_MARGIN,
282            self::VANCHOR_PAGE,
283        ];
284        $this->vertAnchor = $this->setEnumVal($value, $enum, $this->vertAnchor);
285
286        return $this;
287    }
288
289    /**
290     * Get table horizontal anchor.
291     *
292     * @return string
293     */
294    public function getHorzAnchor()
295    {
296        return $this->horzAnchor;
297    }
298
299    /**
300     * Set table horizontal anchor.
301     *
302     * @param string $value
303     *
304     * @return self
305     */
306    public function setHorzAnchor($value = null)
307    {
308        $enum = [
309            self::HANCHOR_TEXT,
310            self::HANCHOR_MARGIN,
311            self::HANCHOR_PAGE,
312        ];
313        $this->horzAnchor = $this->setEnumVal($value, $enum, $this->horzAnchor);
314
315        return $this;
316    }
317
318    /**
319     * Get relative horizontal alignment from anchor.
320     *
321     * @return string
322     */
323    public function getTblpXSpec()
324    {
325        return $this->tblpXSpec;
326    }
327
328    /**
329     * Set relative horizontal alignment from anchor.
330     *
331     * @param string $value
332     *
333     * @return self
334     */
335    public function setTblpXSpec($value = null)
336    {
337        $enum = [
338            self::XALIGN_LEFT,
339            self::XALIGN_CENTER,
340            self::XALIGN_RIGHT,
341            self::XALIGN_INSIDE,
342            self::XALIGN_OUTSIDE,
343        ];
344        $this->tblpXSpec = $this->setEnumVal($value, $enum, $this->tblpXSpec);
345
346        return $this;
347    }
348
349    /**
350     * Get absolute horizontal distance from anchor.
351     *
352     * @return int
353     */
354    public function getTblpX()
355    {
356        return $this->tblpX;
357    }
358
359    /**
360     * Set absolute horizontal distance from anchor.
361     *
362     * @param int $value
363     *
364     * @return self
365     */
366    public function setTblpX($value = null)
367    {
368        $this->tblpX = $this->setNumericVal($value, $this->tblpX);
369
370        return $this;
371    }
372
373    /**
374     * Get relative vertical alignment from anchor.
375     *
376     * @return string
377     */
378    public function getTblpYSpec()
379    {
380        return $this->tblpYSpec;
381    }
382
383    /**
384     * Set relative vertical alignment from anchor.
385     *
386     * @param string $value
387     *
388     * @return self
389     */
390    public function setTblpYSpec($value = null)
391    {
392        $enum = [
393            self::YALIGN_INLINE,
394            self::YALIGN_TOP,
395            self::YALIGN_CENTER,
396            self::YALIGN_BOTTOM,
397            self::YALIGN_INSIDE,
398            self::YALIGN_OUTSIDE,
399        ];
400        $this->tblpYSpec = $this->setEnumVal($value, $enum, $this->tblpYSpec);
401
402        return $this;
403    }
404
405    /**
406     * Get absolute vertical distance from anchor.
407     *
408     * @return int
409     */
410    public function getTblpY()
411    {
412        return $this->tblpY;
413    }
414
415    /**
416     * Set absolute vertical distance from anchor.
417     *
418     * @param int $value
419     *
420     * @return self
421     */
422    public function setTblpY($value = null)
423    {
424        $this->tblpY = $this->setNumericVal($value, $this->tblpY);
425
426        return $this;
427    }
428}