1 | <?php |
||
14 | class BorderPart |
||
15 | { |
||
16 | /** |
||
17 | * @var string The style of this border part. |
||
18 | */ |
||
19 | protected $style; |
||
20 | |||
21 | /** |
||
22 | * @var string The name of this border part. |
||
23 | */ |
||
24 | protected $name; |
||
25 | |||
26 | /** |
||
27 | * @var string The color of this border part. |
||
28 | */ |
||
29 | protected $color; |
||
30 | |||
31 | /** |
||
32 | * @var string The width of this border part. |
||
33 | */ |
||
34 | protected $width; |
||
35 | |||
36 | /** |
||
37 | * @var array Allowed style constants for parts. |
||
38 | */ |
||
39 | protected static $allowedStyles = [ |
||
40 | 'none', |
||
41 | 'solid', |
||
42 | 'dashed', |
||
43 | 'dotted', |
||
44 | 'double' |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * @var array Allowed names constants for border parts. |
||
49 | */ |
||
50 | protected static $allowedNames = [ |
||
51 | 'left', |
||
52 | 'right', |
||
53 | 'top', |
||
54 | 'bottom', |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * @var array Allowed width constants for border parts. |
||
59 | */ |
||
60 | protected static $allowedWidths = [ |
||
61 | 'thin', |
||
62 | 'medium', |
||
63 | 'thick', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * @param string $name @see BorderPart::$allowedNames |
||
68 | * @param string $color A RGB color code |
||
69 | * @param string $width @see BorderPart::$allowedWidths |
||
70 | * @param string $style @see BorderPart::$allowedStyles |
||
71 | * @throws InvalidNameException |
||
72 | * @throws InvalidStyleException |
||
73 | * @throws InvalidWidthException |
||
74 | */ |
||
75 | 16 | public function __construct($name, $color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID) |
|
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | 13 | public function getName() |
|
90 | |||
91 | /** |
||
92 | * @param string $name The name of the border part @see BorderPart::$allowedNames |
||
93 | * @throws InvalidNameException |
||
94 | * @return void |
||
95 | */ |
||
96 | 16 | public function setName($name) |
|
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | 6 | public function getStyle() |
|
111 | |||
112 | /** |
||
113 | * @param string $style The style of the border part @see BorderPart::$allowedStyles |
||
114 | * @throws InvalidStyleException |
||
115 | * @return void |
||
116 | */ |
||
117 | 14 | public function setStyle($style) |
|
124 | |||
125 | /** |
||
126 | * @return string |
||
127 | */ |
||
128 | 6 | public function getColor() |
|
132 | |||
133 | /** |
||
134 | * @param string $color The color of the border part @see Color::rgb() |
||
135 | * @return void |
||
136 | */ |
||
137 | 15 | public function setColor($color) |
|
141 | |||
142 | /** |
||
143 | * @return string |
||
144 | */ |
||
145 | 6 | public function getWidth() |
|
149 | |||
150 | /** |
||
151 | * @param string $width The width of the border part @see BorderPart::$allowedWidths |
||
152 | * @throws InvalidWidthException |
||
153 | * @return void |
||
154 | */ |
||
155 | 15 | public function setWidth($width) |
|
162 | |||
163 | /** |
||
164 | * @return array |
||
165 | */ |
||
166 | 2 | public static function getAllowedStyles() |
|
170 | |||
171 | /** |
||
172 | * @return array |
||
173 | */ |
||
174 | 2 | public static function getAllowedNames() |
|
178 | |||
179 | /** |
||
180 | * @return array |
||
181 | */ |
||
182 | 2 | public static function getAllowedWidths() |
|
186 | } |
||
187 |