Example #1
0
 /**
  * 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) : '');
 }
Example #2
0
 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'));
 }
Example #3
0
 /**
  * Sets rgb
  *
  * @param  string $rgb
  * @return self
  */
 public function setRgb($rgb)
 {
     return $this->setProperty('rgb', Text::isRgb(trim($rgb)) ? trim($rgb) : '');
 }
Example #4
0
 public function testIsRgb()
 {
     $color = $this->faker->hexcolor;
     $this->assertTrue(Text::isRgb($color));
     $this->assertFalse(Text::isRgb('#' . $this->faker->word));
 }