src/Sparkline/StyleTrait.php
protected function colorHexToRGB($color)
    {
        if (!$this->checkColorHex($color)) {
            throw new \InvalidArgumentException('Invalid hexadecimal value ' . $color);
        }

        $color = mb_strtolower($color);
        $color = ltrim($color, '#');
        if (mb_strlen($color) === static::HEXADECIMAL_ALIAS_LENGTH) {
            $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
        }
        $color = hexdec($color);

        return [
            0xFF & ($color >> 0x10), // Red
            0xFF & ($color >> 0x8), // Green
            0xFF & $color, // Blue
        ];
    }
protected function colorHexToRGB($color)
    {
        if (!$this->checkColorHex($color)) {
            throw new \InvalidArgumentException('Invalid hexadecimal value ' . $color);
        }

        $color = mb_strtolower($color);
        $color = ltrim($color, '#');
        if (mb_strlen($color) === static::HEXADECIMAL_ALIAS_LENGTH) {
            $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];
        }
        $color = hexdec($color);

        return [
            0xFF & ($color >> 0x10), // Red
            0xFF & ($color >> 0x8), // Green
            0xFF & $color, // Blue
        ];
    }
protected function colorHexToRGB ( $ color ) { if ( ! $ this -> checkColorHex ( $ color ) ) { throw new \ InvalidArgumentException ( 'Invalid hexadecimal value ' . $ color ) ; } $ color = mb_strtolower ( $ color ) ; $ color = ltrim ( $ color , '#' ) ; if ( mb_strlen ( $ color ) === static :: HEXADECIMAL_ALIAS_LENGTH ) { $ color = $ color [ 0 ] . $ color [ 0 ] . $ color [ 1 ] . $ color [ 1 ] . $ color [ 2 ] . $ color [ 2 ] ; } $ color = hexdec ( $ color ) ; return [ 0xFF & ( $ color >> 0x10 ) , // Red 0xFF & ( $ color >> 0x8 ) , // Green 0xFF & $ color , // Blue ] ; }
@param string $color (hexadecimal)
@exceptions \InvalidArgumentException

@return array (r,g,b)
@param string $color ( hexadecimal ) @exceptions \ InvalidArgumentException