From 9434700799f45b4b9e57766dc0c0d5bb3ec19752 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 17 Feb 2013 14:57:42 +0000 Subject: [PATCH] Simplify getRed, Green and Blue methods for colour styles --- Classes/PHPExcel/Style/Color.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Classes/PHPExcel/Style/Color.php b/Classes/PHPExcel/Style/Color.php index ac004db..d1aaeb0 100644 --- a/Classes/PHPExcel/Style/Color.php +++ b/Classes/PHPExcel/Style/Color.php @@ -263,11 +263,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel * @return string The red colour component */ public static function getRed($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 2, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 0, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 6, $hex); } /** @@ -279,11 +275,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel * @return string The green colour component */ public static function getGreen($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 4, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 2, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 4, $hex); } /** @@ -295,11 +287,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel * @return string The blue colour component */ public static function getBlue($RGB,$hex=TRUE) { - if (strlen($RGB) == 8) { - return self::_getColourComponent($RGB, 6, $hex); - } elseif (strlen($RGB) == 6) { - return self::_getColourComponent($RGB, 4, $hex); - } + return self::_getColourComponent($RGB, strlen($RGB) - 2, $hex); } /**