/** * Gets or sets rgb * * @param string $rgb * @return string|self */ public function rgb($rgb = null) { if (null === $rgb) { return $this->property('rgb'); } return $this->property('rgb', Text::isRgb(trim($rgb)) ? trim($rgb) : ''); }
public function testIsRgb() { $this->assertTrue(Text::isRgb('#112233')); $this->assertTrue(Text::isRgb('#1122ff')); $this->assertTrue(Text::isRgb('#11ff33')); $this->assertTrue(Text::isRgb('#ff2233')); $this->assertTrue(Text::isRgb('#aabbcc')); $this->assertFalse(Text::isRgb('#1122gg')); $this->assertFalse(Text::isRgb('#11gg33')); $this->assertFalse(Text::isRgb('#gg2233')); $this->assertFalse(Text::isRgb('#aabbgg')); $this->assertFalse(Text::isRgb('#aaggcc')); $this->assertFalse(Text::isRgb('#ggbbcc')); }
/** * Sets rgb * * @param string $rgb * @return self */ public function setRgb($rgb) { return $this->setProperty('rgb', Text::isRgb(trim($rgb)) ? trim($rgb) : ''); }
public function testIsRgb() { $color = $this->faker->hexcolor; $this->assertTrue(Text::isRgb($color)); $this->assertFalse(Text::isRgb('#' . $this->faker->word)); }