Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
11 / 11 |
CRAP | |
100.00% |
1 / 1 |
| Style | |
100.00% |
18 / 18 |
|
100.00% |
11 / 11 |
13 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| create | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setFont | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getFont | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasFont | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSize | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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\Pdf\Document; |
| 15 | |
| 16 | /** |
| 17 | * Pdf style class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\Pdf |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 5.2.7 |
| 25 | */ |
| 26 | class Style |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Style name |
| 31 | * @var ?string |
| 32 | */ |
| 33 | protected ?string $name = null; |
| 34 | |
| 35 | /** |
| 36 | * Style font |
| 37 | * @var ?string |
| 38 | */ |
| 39 | protected ?string $font = null; |
| 40 | |
| 41 | /** |
| 42 | * Style size |
| 43 | * @var int|float|null |
| 44 | */ |
| 45 | protected int|float|null $size = null; |
| 46 | |
| 47 | /** |
| 48 | * Constructor |
| 49 | * |
| 50 | * Instantiate a PDF style. |
| 51 | * |
| 52 | * @param string $name |
| 53 | * @param ?string $font |
| 54 | * @param int|float|null $size |
| 55 | */ |
| 56 | public function __construct(string $name, ?string $font = null, int|float|null $size = null) |
| 57 | { |
| 58 | $this->setName($name); |
| 59 | if ($font !== null) { |
| 60 | $this->setFont($font); |
| 61 | } |
| 62 | if ($size !== null) { |
| 63 | $this->setSize($size); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Create style object |
| 69 | * |
| 70 | * @param string $name |
| 71 | * @param ?string $font |
| 72 | * @param int|float|null $size |
| 73 | * @return Style |
| 74 | */ |
| 75 | public static function create(string $name, ?string $font = null, int|float|null $size = null): Style |
| 76 | { |
| 77 | return new self($name, $font, $size); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Set name |
| 82 | * |
| 83 | * @param string $name |
| 84 | * @return Style |
| 85 | */ |
| 86 | public function setName(string $name): Style |
| 87 | { |
| 88 | $this->name = $name; |
| 89 | return $this; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Get name |
| 94 | * |
| 95 | * @return ?string |
| 96 | */ |
| 97 | public function getName(): ?string |
| 98 | { |
| 99 | return $this->name; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Has name |
| 104 | * |
| 105 | * @return bool |
| 106 | */ |
| 107 | public function hasName(): bool |
| 108 | { |
| 109 | return ($this->name !== null); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Set font |
| 114 | * |
| 115 | * @param string $font |
| 116 | * @return Style |
| 117 | */ |
| 118 | public function setFont(string $font): Style |
| 119 | { |
| 120 | $this->font = $font; |
| 121 | return $this; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Get font |
| 126 | * |
| 127 | * @return ?string |
| 128 | */ |
| 129 | public function getFont(): ?string |
| 130 | { |
| 131 | return $this->font; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Has font |
| 136 | * |
| 137 | * @return bool |
| 138 | */ |
| 139 | public function hasFont(): bool |
| 140 | { |
| 141 | return ($this->font !== null); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Set size |
| 146 | * |
| 147 | * @param int|float $size |
| 148 | * @return Style |
| 149 | */ |
| 150 | public function setSize(int|float $size): Style |
| 151 | { |
| 152 | $this->size = $size; |
| 153 | return $this; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Get size |
| 158 | * |
| 159 | * @return int|float|null |
| 160 | */ |
| 161 | public function getSize(): int|float|null |
| 162 | { |
| 163 | return $this->size; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Has size |
| 168 | * |
| 169 | * @return bool |
| 170 | */ |
| 171 | public function hasSize(): bool |
| 172 | { |
| 173 | return ($this->size !== null); |
| 174 | } |
| 175 | |
| 176 | } |