1 | <?php |
||
12 | class BorderPart |
||
13 | { |
||
14 | /** |
||
15 | * @var string The style of this border part. |
||
16 | */ |
||
17 | protected $style; |
||
18 | |||
19 | /** |
||
20 | * @var string The name of this border part. |
||
21 | */ |
||
22 | protected $name; |
||
23 | |||
24 | /** |
||
25 | * @var string The color of this border part. |
||
26 | */ |
||
27 | protected $color; |
||
28 | |||
29 | /** |
||
30 | * @var string The width of this border part. |
||
31 | */ |
||
32 | protected $width; |
||
33 | |||
34 | /** |
||
35 | * @var array Allowed style constants for parts. |
||
36 | */ |
||
37 | protected static $allowedStyles = [ |
||
38 | 'none', |
||
39 | 'solid', |
||
40 | 'dashed', |
||
41 | 'dotted', |
||
42 | 'double' |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * @var array Allowed names constants for border parts. |
||
47 | */ |
||
48 | protected static $allowedNames = [ |
||
49 | 'left', |
||
50 | 'right', |
||
51 | 'top', |
||
52 | 'bottom', |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * @var array Allowed width constants for border parts. |
||
57 | */ |
||
58 | protected static $allowedWidths = [ |
||
59 | 'thin', |
||
60 | 'medium', |
||
61 | 'thick', |
||
62 | ]; |
||
63 | |||
64 | /** |
||
65 | * @param string $name @see BorderPart::$allowedNames |
||
66 | * @param string $color A RGB color code |
||
67 | * @param string $width @see BorderPart::$allowedWidths |
||
68 | * @param string $style @see BorderPart::$allowedStyles |
||
69 | * @throws InvalidNameException |
||
70 | * @throws InvalidStyleException |
||
71 | * @throws InvalidWidthException |
||
72 | */ |
||
73 | public function __construct($name, $color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) |
||
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getName() |
||
88 | |||
89 | /** |
||
90 | * @param string $name The name of the border part @see BorderPart::$allowedNames |
||
91 | * @throws InvalidNameException |
||
92 | * @return void |
||
93 | */ |
||
94 | public function setName($name) |
||
101 | |||
102 | /** |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getStyle() |
||
109 | |||
110 | /** |
||
111 | * @param string $style The style of the border part @see BorderPart::$allowedStyles |
||
112 | * @throws InvalidStyleException |
||
113 | * @return void |
||
114 | */ |
||
115 | public function setStyle($style) |
||
122 | |||
123 | /** |
||
124 | * @return string |
||
125 | */ |
||
126 | public function getColor() |
||
130 | |||
131 | /** |
||
132 | * @param string $color The color of the border part @see Color::rgb() |
||
133 | * @return void |
||
134 | */ |
||
135 | public function setColor($color) |
||
139 | |||
140 | /** |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getWidth() |
||
147 | |||
148 | /** |
||
149 | * @param string $width The width of the border part @see BorderPart::$allowedWidths |
||
150 | * @throws InvalidWidthException |
||
151 | * @return void |
||
152 | */ |
||
153 | public function setWidth($width) |
||
160 | |||
161 | /** |
||
162 | * @return array |
||
163 | */ |
||
164 | public static function getAllowedStyles() |
||
168 | |||
169 | /** |
||
170 | * @return array |
||
171 | */ |
||
172 | public static function getAllowedNames() |
||
176 | |||
177 | /** |
||
178 | * @return array |
||
179 | */ |
||
180 | public static function getAllowedWidths() |
||
184 | } |
||
185 |