1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-24 09:19:50 +01:00

changed hexcolor selector from array to decimal for a bit faster query

This commit is contained in:
lsv 2013-06-17 20:58:42 +02:00
parent e088a2e625
commit 6d30f63245

View File

@ -11,11 +11,6 @@ namespace Faker\Provider;
class Color extends Base
{
protected static $hexcodes = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'
);
protected static $safeColorNames = array(
'black', 'maroon', 'green', 'navy', 'olive',
'purple', 'teal', 'lime', 'blue', 'silver',
@ -57,12 +52,12 @@ class Color extends Base
public static function hexColor()
{
return sprintf('#%s%s%s%s%s%s',
static::randomElement(static::$hexcodes),
static::randomElement(static::$hexcodes),
static::randomElement(static::$hexcodes),
static::randomElement(static::$hexcodes),
static::randomElement(static::$hexcodes),
static::randomElement(static::$hexcodes)
dechex(static::numberBetween(0,15)),
dechex(static::numberBetween(0,15)),
dechex(static::numberBetween(0,15)),
dechex(static::numberBetween(0,15)),
dechex(static::numberBetween(0,15)),
dechex(static::numberBetween(0,15))
);
}
@ -71,9 +66,9 @@ class Color extends Base
*/
public static function safeHexColor()
{
$color1 = static::randomElement(static::$hexcodes);
$color2 = static::randomElement(static::$hexcodes);
$color3 = static::randomElement(static::$hexcodes);
$color1 = dechex(static::numberBetween(0,15));
$color2 = dechex(static::numberBetween(0,15));
$color3 = dechex(static::numberBetween(0,15));
return sprintf('#%s%s%s%s%s%s',
$color1,
$color1,