Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
14 / 14 |
CRAP | |
100.00% |
1 / 1 |
AbstractAlignment | |
100.00% |
21 / 21 |
|
100.00% |
14 / 14 |
14 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
setAlignment | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setLeftX | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setRightX | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
setLeading | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAlignment | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLeftX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRightX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLeading | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasLeftX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasRightX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasLeading | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isLeft | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isRight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Pdf\Document\Page\Text; |
15 | |
16 | /** |
17 | * Pdf page text abstract alignment class |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Pdf |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 5.0.0 |
25 | */ |
26 | abstract class AbstractAlignment implements AlignmentInterface |
27 | { |
28 | |
29 | /** |
30 | * Alignment constants |
31 | */ |
32 | const LEFT = 'LEFT'; |
33 | const RIGHT = 'RIGHT'; |
34 | |
35 | /** |
36 | * Text alignment |
37 | * @var string |
38 | */ |
39 | protected string $alignment = self::LEFT; |
40 | |
41 | /** |
42 | * Left X boundary |
43 | * @var int |
44 | */ |
45 | protected int $leftX = 0; |
46 | |
47 | /** |
48 | * Right X boundary |
49 | * @var int |
50 | */ |
51 | protected int $rightX = 0; |
52 | |
53 | /** |
54 | * Text leading |
55 | * @var int |
56 | */ |
57 | protected int $leading = 0; |
58 | |
59 | /** |
60 | * Constructor |
61 | * |
62 | * Instantiate a PDF text alignment object. |
63 | * |
64 | * @param string $alignment |
65 | * @param int $leftX |
66 | * @param int $rightX |
67 | * @param int $leading |
68 | */ |
69 | public function __construct(string $alignment = self::LEFT, int $leftX = 0, int $rightX = 0, int $leading = 0) |
70 | { |
71 | $this->setAlignment($alignment); |
72 | $this->setLeftX($leftX); |
73 | $this->setRightX($rightX); |
74 | $this->setLeading($leading); |
75 | } |
76 | |
77 | /** |
78 | * Set alignment |
79 | * |
80 | * @param string $alignment |
81 | * @return AbstractAlignment |
82 | */ |
83 | public function setAlignment(string $alignment): AbstractAlignment |
84 | { |
85 | $this->alignment = $alignment; |
86 | return $this; |
87 | } |
88 | |
89 | /** |
90 | * Set the left X boundary |
91 | * |
92 | * @param int $x |
93 | * @return AbstractAlignment |
94 | */ |
95 | public function setLeftX(int $x): AbstractAlignment |
96 | { |
97 | $this->leftX = $x; |
98 | return $this; |
99 | } |
100 | |
101 | /** |
102 | * Set the right X boundary |
103 | * |
104 | * @param int $x |
105 | * @return AbstractAlignment |
106 | */ |
107 | public function setRightX(int $x): AbstractAlignment |
108 | { |
109 | $this->rightX = $x; |
110 | return $this; |
111 | } |
112 | |
113 | /** |
114 | * Set the leading |
115 | * |
116 | * @param int $leading |
117 | * @return AbstractAlignment |
118 | */ |
119 | public function setLeading(int $leading): AbstractAlignment |
120 | { |
121 | $this->leading = $leading; |
122 | return $this; |
123 | } |
124 | |
125 | /** |
126 | * Get alignment |
127 | * |
128 | * @return string |
129 | */ |
130 | public function getAlignment(): string |
131 | { |
132 | return $this->alignment; |
133 | } |
134 | |
135 | /** |
136 | * Get the left X |
137 | * |
138 | * @return int |
139 | */ |
140 | public function getLeftX(): int |
141 | { |
142 | return $this->leftX; |
143 | } |
144 | |
145 | /** |
146 | * Get the right X |
147 | * |
148 | * @return int |
149 | */ |
150 | public function getRightX(): int |
151 | { |
152 | return $this->rightX; |
153 | } |
154 | |
155 | /** |
156 | * Get the leading |
157 | * |
158 | * @return int |
159 | */ |
160 | public function getLeading(): int |
161 | { |
162 | return $this->leading; |
163 | } |
164 | |
165 | /** |
166 | * Has left X |
167 | * |
168 | * @return bool |
169 | */ |
170 | public function hasLeftX(): bool |
171 | { |
172 | return ($this->leftX > 0); |
173 | } |
174 | |
175 | /** |
176 | * Has right X |
177 | * |
178 | * @return bool |
179 | */ |
180 | public function hasRightX(): bool |
181 | { |
182 | return ($this->rightX > 0); |
183 | } |
184 | |
185 | /** |
186 | * Has leading |
187 | * |
188 | * @return bool |
189 | */ |
190 | public function hasLeading(): bool |
191 | { |
192 | return ($this->leading > 0); |
193 | } |
194 | |
195 | /** |
196 | * Is LEFT alignment |
197 | * |
198 | * @return bool |
199 | */ |
200 | public function isLeft(): bool |
201 | { |
202 | return ($this->alignment == self::LEFT); |
203 | } |
204 | |
205 | /** |
206 | * Is RIGHT alignment |
207 | * |
208 | * @return bool |
209 | */ |
210 | public function isRight(): bool |
211 | { |
212 | return ($this->alignment == self::RIGHT); |
213 | } |
214 | |
215 | } |