src/SyHolloway/MrColor/Extension/Formatter.php
public function loadHexString(Color $color, $subject)
    {
        $subject = trim($subject);

        $subject = str_replace(array('#', ';', ' '), '', $subject);

        if (strlen($subject) !== 3 && strlen($subject) !== 6) {
            //Bad Input
            return false;
        } elseif (strlen($subject) === 3) {
            $subject = $subject[0] . $subject[0] .
                       $subject[1] . $subject[1] .
                       $subject[2] . $subject[2] ;
        }

        $color->hex = $subject;

        return $color;
    }
public function loadHexString(Color $color, $subject)
    {
        $subject = trim($subject);

        $subject = str_replace(array('#', ';', ' '), '', $subject);

        if (strlen($subject) !== 3 && strlen($subject) !== 6) {
            //Bad Input
            return false;
        } elseif (strlen($subject) === 3) {
            $subject = $subject[0] . $subject[0] .
                       $subject[1] . $subject[1] .
                       $subject[2] . $subject[2] ;
        }

        $color->hex = $subject;

        return $color;
    }
public function loadHexString ( Color $ color , $ subject ) { $ subject = trim ( $ subject ) ; $ subject = str_replace ( array ( '#' , ';' , ' ' ) , '' , $ subject ) ; if ( strlen ( $ subject ) !== 3 && strlen ( $ subject ) !== 6 ) { //Bad Input return false ; } elseif ( strlen ( $ subject ) === 3 ) { $ subject = $ subject [ 0 ] . $ subject [ 0 ] . $ subject [ 1 ] . $ subject [ 1 ] . $ subject [ 2 ] . $ subject [ 2 ] ; } $ color -> hex = $ subject ; return $ color ; }
Loads a color object from a hex string

@param object $color Color object
@param mixed
@return object Color object
Loads a color object from a hex string