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