Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
13 / 13
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractType
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
13 / 13
13
100.00% covered (success)
100.00%
1 / 1
 getOpacity
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFillColor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStrokeColor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getStrokeWidth
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setFillColor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setStrokeColor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setStrokeWidth
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 size
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 font
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 x
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 y
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 xy
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 rotate
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setOpacity
n/a
0 / 0
n/a
0 / 0
0
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <dev@noladev.com>
8 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Image\Type;
16
17use Pop\Image\AbstractEditObject;
18use Pop\Color\Color;
19
20/**
21 * Type abstract class
22 *
23 * @category   Pop
24 * @package    Pop\Image
25 * @author     Nick Sagona, III <dev@noladev.com>
26 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
27 * @license    https://www.popphp.org/license     New BSD License
28 * @version    5.0.0
29 */
30abstract class AbstractType extends AbstractEditObject implements TypeInterface
31{
32
33    /**
34     * Type font size
35     * @var int
36     */
37    protected int $size = 12;
38
39    /**
40     * Type font
41     * @var ?string
42     */
43    protected ?string $font = null;
44
45    /**
46     * Fill color
47     * @var ?Color\ColorInterface
48     */
49    protected ?Color\ColorInterface $fillColor = null;
50
51    /**
52     * Stroke color
53     * @var ?Color\ColorInterface
54     */
55    protected ?Color\ColorInterface $strokeColor = null;
56
57    /**
58     * Stroke width
59     * @var int
60     */
61    protected int $strokeWidth = 1;
62
63    /**
64     * Type X-position
65     * @var int
66     */
67    protected int $x = 0;
68
69    /**
70     * Type Y-position
71     * @var int
72     */
73    protected int $y = 0;
74
75    /**
76     * Type rotation in degrees
77     * @var int
78     */
79    protected int $rotation = 0;
80
81    /**
82     * Opacity
83     * @var int|float|null
84     */
85    protected int|float|null $opacity = null;
86
87    /**
88     * Get the opacity
89     *
90     * @return int|float|null
91     */
92    public function getOpacity(): int|float|null
93    {
94        return $this->opacity;
95    }
96
97    /**
98     * Get fill color
99     *
100     * @return Color\ColorInterface
101     */
102    public function getFillColor(): Color\ColorInterface
103    {
104        return $this->fillColor;
105    }
106
107    /**
108     * Get stroke color
109     *
110     * @return Color\ColorInterface
111     */
112    public function getStrokeColor(): Color\ColorInterface
113    {
114        return $this->strokeColor;
115    }
116
117    /**
118     * Get stroke width
119     *
120     * @return int
121     */
122    public function getStrokeWidth(): int
123    {
124        return $this->strokeWidth;
125    }
126
127    /**
128     * Set fill color
129     *
130     * @param  Color\ColorInterface $color
131     * @return AbstractType
132     */
133    public function setFillColor(Color\ColorInterface $color): AbstractType
134    {
135        $this->fillColor = $color;
136        return $this;
137    }
138
139    /**
140     * Set stroke color
141     *
142     * @param  Color\ColorInterface $color
143     * @return AbstractType
144     */
145    public function setStrokeColor(Color\ColorInterface $color): AbstractType
146    {
147        $this->strokeColor = $color;
148        return $this;
149    }
150
151    /**
152     * Set stroke width
153     *
154     * @param  int $w
155     * @return AbstractType
156     */
157    public function setStrokeWidth(int $w): AbstractType
158    {
159        $this->strokeWidth = $w;
160        return $this;
161    }
162
163    /**
164     * Set the font size
165     *
166     * @param  int $size
167     * @return AbstractType
168     */
169    public function size(int $size): AbstractType
170    {
171        $this->size = (int)$size;
172        return $this;
173    }
174
175    /**
176     * Set the font
177     *
178     * @param  string $font
179     * @return AbstractType
180     */
181    public function font(string $font): AbstractType
182    {
183        $this->font = $font;
184        return $this;
185    }
186
187    /**
188     * Set the X-position
189     *
190     * @param  int $x
191     * @return AbstractType
192     */
193    public function x(int $x): AbstractType
194    {
195        $this->x = (int)$x;
196        return $this;
197    }
198
199    /**
200     * Set the Y-position
201     *
202     * @param  int $y
203     * @return AbstractType
204     */
205    public function y(int $y): AbstractType
206    {
207        $this->y = (int)$y;
208        return $this;
209    }
210
211    /**
212     * Set both the X- and Y-positions
213     *
214     * @param  int $x
215     * @param  int $y
216     * @return AbstractType
217     */
218    public function xy(int $x, int $y): AbstractType
219    {
220        $this->x($x);
221        $this->y($y);
222        return $this;
223    }
224
225    /**
226     * Set the rotation of the text
227     *
228     * @param  int $degrees
229     * @return AbstractType
230     */
231    public function rotate(int $degrees): AbstractType
232    {
233        $this->rotation = (int)$degrees;
234        return $this;
235    }
236
237    /**
238     * Set the opacity
239     *
240     * @param  int|float $opacity
241     * @return AbstractType
242     */
243    abstract public function setOpacity(int|float$opacity): AbstractType;
244
245}