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

added rgbCssColor method

This commit is contained in:
lsv 2013-06-17 01:35:10 +02:00
parent 9ce3d44ea2
commit e088a2e625
3 changed files with 15 additions and 0 deletions

View File

@ -191,6 +191,7 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle
hexcolor // '#fa3cc2'
rgbcolor // '0,255,122'
rgbColorAsArray // array(0,255,122)
rgbCssColor // 'rgb(0,255,122)'
safeColorName // 'fuchsia'
colorName // 'Gainsbor'

View File

@ -105,6 +105,14 @@ class Color extends Base
return implode(',', static::rgbColorAsArray());
}
/**
* @example 'rgb(0,255,122)'
*/
public static function rgbCssColor()
{
return 'rgb(' . static::rgbColor() . ')';
}
/**
* @example 'blue'
*/

View File

@ -23,4 +23,10 @@ class ColorTest extends \PHPUnit_Framework_TestCase
$this->assertRegExp('/^' . $regexp . ',' . $regexp . ',' . $regexp . '$/i', Color::rgbColor());
}
public function testRgbCssColor()
{
$regexp = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])';
$this->assertRegExp('/^rgb\(' . $regexp . ',' . $regexp . ',' . $regexp . '\)$/i', Color::rgbCssColor());
}
}