Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
9 / 9
CRAP
100.00% covered (success)
100.00%
1 / 1
Spacing
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
9 / 9
9
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
 getBefore
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBefore
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAfter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAfter
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getLine
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLine
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getLineRule
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLineRule
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
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\Style;
20
21use PhpOffice\PhpWord\SimpleType\LineSpacingRule;
22
23/**
24 * Spacing between lines and above/below paragraph style.
25 *
26 * @see  http://www.datypic.com/sc/ooxml/t-w_CT_Spacing.html
27 * @since 0.10.0
28 */
29class Spacing extends AbstractStyle
30{
31    /**
32     * Spacing above paragraph (twip).
33     *
34     * @var null|float|int
35     */
36    private $before;
37
38    /**
39     * Spacing below paragraph (twip).
40     *
41     * @var null|float|int
42     */
43    private $after;
44
45    /**
46     * Spacing between lines in paragraph (twip).
47     *
48     * @var null|float|int
49     */
50    private $line;
51
52    /**
53     * Type of spacing between lines.
54     *
55     * @var string
56     */
57    private $lineRule = LineSpacingRule::AUTO;
58
59    /**
60     * Create a new instance.
61     *
62     * @param array $style
63     */
64    public function __construct($style = [])
65    {
66        $this->setStyleByArray($style);
67    }
68
69    /**
70     * Get before.
71     *
72     * @return null|float|int
73     */
74    public function getBefore()
75    {
76        return $this->before;
77    }
78
79    /**
80     * Set before.
81     *
82     * @param null|float|int $value
83     *
84     * @return self
85     */
86    public function setBefore($value = null)
87    {
88        $this->before = $this->setNumericVal($value, $this->before);
89
90        return $this;
91    }
92
93    /**
94     * Get after.
95     *
96     * @return null|float|int
97     */
98    public function getAfter()
99    {
100        return $this->after;
101    }
102
103    /**
104     * Set after.
105     *
106     * @param null|float|int $value
107     *
108     * @return self
109     */
110    public function setAfter($value = null)
111    {
112        $this->after = $this->setNumericVal($value, $this->after);
113
114        return $this;
115    }
116
117    /**
118     * Get line.
119     *
120     * @return null|float|int
121     */
122    public function getLine()
123    {
124        return $this->line;
125    }
126
127    /**
128     * Set distance.
129     *
130     * @param null|float|int $value
131     *
132     * @return self
133     */
134    public function setLine($value = null)
135    {
136        $this->line = $this->setNumericVal($value, $this->line);
137
138        return $this;
139    }
140
141    /**
142     * Get line rule.
143     *
144     * @return string
145     */
146    public function getLineRule()
147    {
148        return $this->lineRule;
149    }
150
151    /**
152     * Set line rule.
153     *
154     * @param string $value
155     *
156     * @return self
157     */
158    public function setLineRule($value = null)
159    {
160        LineSpacingRule::validate($value);
161        $this->lineRule = $value;
162
163        return $this;
164    }
165}