@@ -263,11 +263,7 @@ private static function _getColourComponent($RGB,$offset,$hex=TRUE) {
263
263
* @return string The red colour component
264
264
*/
265
265
public static function getRed ($ RGB ,$ hex =TRUE ) {
266
- if (strlen ($ RGB ) == 8 ) {
267
- return self ::_getColourComponent ($ RGB , 2 , $ hex );
268
- } elseif (strlen ($ RGB ) == 6 ) {
269
- return self ::_getColourComponent ($ RGB , 0 , $ hex );
270
- }
266
+ return self ::_getColourComponent ($ RGB , strlen ($ RGB ) - 6 , $ hex );
271
267
}
272
268
273
269
/**
@@ -279,11 +275,7 @@ public static function getRed($RGB,$hex=TRUE) {
279
275
* @return string The green colour component
280
276
*/
281
277
public static function getGreen ($ RGB ,$ hex =TRUE ) {
282
- if (strlen ($ RGB ) == 8 ) {
283
- return self ::_getColourComponent ($ RGB , 4 , $ hex );
284
- } elseif (strlen ($ RGB ) == 6 ) {
285
- return self ::_getColourComponent ($ RGB , 2 , $ hex );
286
- }
278
+ return self ::_getColourComponent ($ RGB , strlen ($ RGB ) - 4 , $ hex );
287
279
}
288
280
289
281
/**
@@ -295,11 +287,7 @@ public static function getGreen($RGB,$hex=TRUE) {
295
287
* @return string The blue colour component
296
288
*/
297
289
public static function getBlue ($ RGB ,$ hex =TRUE ) {
298
- if (strlen ($ RGB ) == 8 ) {
299
- return self ::_getColourComponent ($ RGB , 6 , $ hex );
300
- } elseif (strlen ($ RGB ) == 6 ) {
301
- return self ::_getColourComponent ($ RGB , 4 , $ hex );
302
- }
290
+ return self ::_getColourComponent ($ RGB , strlen ($ RGB ) - 2 , $ hex );
303
291
}
304
292
305
293
/**
0 commit comments