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

        $subject = str_replace(array('hsla', 'hsl', '(', ')', ';', ' '), '', $subject);

        $hslnum = explode(',', $subject);

        if (count($hslnum) !== 3 && count($hslnum) !== 4) {
            return false;
        }

        foreach ($hslnum as &$val) {
            $val = floatval(trim($val));
        }

        $hsl = array(
            'hue' => $hslnum[0],
            'saturation' => $hslnum[1],
            'lightness' => $hslnum[2]
        );

        if (isset($hslnum[3])) {
            $hsl['alpha'] = $hslnum[3];
        }

        $color->bulkUpdate($hsl);

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

        $subject = str_replace(array('hsla', 'hsl', '(', ')', ';', ' '), '', $subject);

        $hslnum = explode(',', $subject);

        if (count($hslnum) !== 3 && count($hslnum) !== 4) {
            return false;
        }

        foreach ($hslnum as &$val) {
            $val = floatval(trim($val));
        }

        $hsl = array(
            'hue' => $hslnum[0],
            'saturation' => $hslnum[1],
            'lightness' => $hslnum[2]
        );

        if (isset($hslnum[3])) {
            $hsl['alpha'] = $hslnum[3];
        }

        $color->bulkUpdate($hsl);

        return $color;
    }
public function loadHslString ( Color $ color , $ subject ) { $ subject = trim ( $ subject ) ; $ subject = str_replace ( array ( 'hsla' , 'hsl' , '(' , ')' , ';' , ' ' ) , '' , $ subject ) ; $ hslnum = explode ( ',' , $ subject ) ; if ( count ( $ hslnum ) !== 3 && count ( $ hslnum ) !== 4 ) { return false ; } foreach ( $ hslnum as & $ val ) { $ val = floatval ( trim ( $ val ) ) ; } $ hsl = array ( 'hue' => $ hslnum [ 0 ] , 'saturation' => $ hslnum [ 1 ] , 'lightness' => $ hslnum [ 2 ] ) ; if ( isset ( $ hslnum [ 3 ] ) ) { $ hsl [ 'alpha' ] = $ hslnum [ 3 ] ; } $ color -> bulkUpdate ( $ hsl ) ; return $ color ; }
Loads a color object from a hsl or hsla string

@param object $color Color object
@param mixed
@return object Color object
Loads a color object from a hsl or hsla string