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