public static function name($color) {

		if(false === is_string($color)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($color)), E_USER_ERROR);
		}

		if(1 !== preg_match('#^[0-9a-fA-F]{6,6}$#', $color)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be a 6 character hexadecimal string', __METHOD__), E_USER_ERROR);
		}

		$color 	= strtoupper($color);
		$rgb 	= static :: rgb($color);
		$r 		= $rgb -> r; 
		$g 		= $rgb -> g; 
		$b 		= $rgb -> b;
		$hsl 	= static :: hsl($color);
		$h 		= $hsl -> h; 
		$s 		= $hsl -> s; 
		$l 		= $hsl -> l;
		$ndf1 	= 0;
		$ndf2 	= 0; 
		$ndf 	= 0;
		$cl 	= -1;
		$df 	= -1;

		//Index all the colors
		if(null === static :: $list) {

			new ColorList();
			static :: index();
		}

		foreach(static :: $list as $hex => $color) {

			$ndf1 = pow($r - $color -> r, 2) + pow($g - $color -> g, 2) + pow($b - $color -> b, 2);
			$ndf2 = pow($h - $color -> h, 2) + pow($s - $color -> s, 2) + pow($l - $color -> l, 2);
			$ndf  = $ndf1 + $ndf2 * 2;

			if($df < 0 || $df > $ndf) {

				$df = $ndf;
				$cl = $hex;
			}
		}

		if(true === isset(static :: $list[$cl])) {
			return static :: $list[$cl];
		}

		return null;
	}
public static function name($color) {

		if(false === is_string($color)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($color)), E_USER_ERROR);
		}

		if(1 !== preg_match('#^[0-9a-fA-F]{6,6}$#', $color)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be a 6 character hexadecimal string', __METHOD__), E_USER_ERROR);
		}

		$color 	= strtoupper($color);
		$rgb 	= static :: rgb($color);
		$r 		= $rgb -> r; 
		$g 		= $rgb -> g; 
		$b 		= $rgb -> b;
		$hsl 	= static :: hsl($color);
		$h 		= $hsl -> h; 
		$s 		= $hsl -> s; 
		$l 		= $hsl -> l;
		$ndf1 	= 0;
		$ndf2 	= 0; 
		$ndf 	= 0;
		$cl 	= -1;
		$df 	= -1;

		//Index all the colors
		if(null === static :: $list) {

			new ColorList();
			static :: index();
		}

		foreach(static :: $list as $hex => $color) {

			$ndf1 = pow($r - $color -> r, 2) + pow($g - $color -> g, 2) + pow($b - $color -> b, 2);
			$ndf2 = pow($h - $color -> h, 2) + pow($s - $color -> s, 2) + pow($l - $color -> l, 2);
			$ndf  = $ndf1 + $ndf2 * 2;

			if($df < 0 || $df > $ndf) {

				$df = $ndf;
				$cl = $hex;
			}
		}

		if(true === isset(static :: $list[$cl])) {
			return static :: $list[$cl];
		}

		return null;
	}
public static function name ( $ color ) { if ( false === is_string ( $ color ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ color ) ) , E_USER_ERROR ) ; } if ( 1 !== preg_match ( '#^[0-9a-fA-F]{6,6}$#' , $ color ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be a 6 character hexadecimal string' , __METHOD__ ) , E_USER_ERROR ) ; } $ color = strtoupper ( $ color ) ; $ rgb = static :: rgb ( $ color ) ; $ r = $ rgb -> r ; $ g = $ rgb -> g ; $ b = $ rgb -> b ; $ hsl = static :: hsl ( $ color ) ; $ h = $ hsl -> h ; $ s = $ hsl -> s ; $ l = $ hsl -> l ; $ ndf1 = 0 ; $ ndf2 = 0 ; $ ndf = 0 ; $ cl = - 1 ; $ df = - 1 ; //Index all the colors
 if ( null === static :: $ list ) { new ColorList ( ) ; static :: index ( ) ; } foreach ( static :: $ list as $ hex => $ color ) { $ ndf1 = pow ( $ r - $ color -> r , 2 ) + pow ( $ g - $ color -> g , 2 ) + pow ( $ b - $ color -> b , 2 ) ; $ ndf2 = pow ( $ h - $ color -> h , 2 ) + pow ( $ s - $ color -> s , 2 ) + pow ( $ l - $ color -> l , 2 ) ; $ ndf = $ ndf1 + $ ndf2 * 2 ; if ( $ df < 0 || $ df > $ ndf ) { $ df = $ ndf ; $ cl = $ hex ; } } if ( true === isset ( static :: $ list [ $ cl ] ) ) { return static :: $ list [ $ cl ] ; } return null ; }
Convert a hexadecimal color to color name in human language
@param string $color
@return null|stdClass Object
Convert a hexadecimal color to color name in human language