library/Theme/ColorScheme.php
public function sanitizeColorSheme($colors)
    {

        //Make array keyless
        $colors = array_values(array_unique((array) $colors));

        //Check if value is valid HEX
        foreach ($colors as $colorKey => $color) {
            if (preg_match('/^#[a-f0-9]{6}$/i', $color)) {
                continue;
            }
            unset($colors[$colorKey]);
        }

        //Sort (base colors at the end)
        usort($colors, function ($a, $b) {
            return strlen($b)-strlen($a);
        });

        return $colors;
    }
public function sanitizeColorSheme($colors)
    {

        //Make array keyless
        $colors = array_values(array_unique((array) $colors));

        //Check if value is valid HEX
        foreach ($colors as $colorKey => $color) {
            if (preg_match('/^#[a-f0-9]{6}$/i', $color)) {
                continue;
            }
            unset($colors[$colorKey]);
        }

        //Sort (base colors at the end)
        usort($colors, function ($a, $b) {
            return strlen($b)-strlen($a);
        });

        return $colors;
    }
public function sanitizeColorSheme ( $ colors ) { //Make array keyless $ colors = array_values ( array_unique ( ( array ) $ colors ) ) ; //Check if value is valid HEX foreach ( $ colors as $ colorKey => $ color ) { if ( preg_match ( '/^#[a-f0-9]{6}$/i' , $ color ) ) { continue ; } unset ( $ colors [ $ colorKey ] ) ; } //Sort (base colors at the end) usort ( $ colors , function ( $ a , $ b ) { return strlen ( $ b ) - strlen ( $ a ) ; } ) ; return $ colors ; }
Remove duplicates etc and make the array stored keyless
@param  array/object $colors A unsanitized arry of colors (must be flat)
@return array
Remove duplicates etc and make the array stored keyless