Phue\Command\SetLightState::rgb PHP Method

rgb() public method

Sets xy and brightness calculated from RGB
public rgb ( integer $red, integer $green, integer $blue ) : self
$red integer Red value
$green integer Green value
$blue integer Blue value
return self This object
    public function rgb($red, $green, $blue)
    {
        // Don't continue if rgb values are invalid
        foreach (array($red, $green, $blue) as $value) {
            if (!(self::RGB_MIN <= $value && $value <= self::RGB_MAX)) {
                throw new \InvalidArgumentException("RGB values must be between " . self::RGB_MIN . " and " . self::RGB_MAX);
            }
        }
        $xy = ColorConversion::convertRGBToXY($red, $green, $blue);
        return $this->xy($xy['x'], $xy['y'])->brightness($xy['bri']);
    }

Usage Example

Example #1
0
 /**
  * Test: invalid RGB value
  *
  * @dataProvider providerInvalidRGB
  *
  * @covers \Phue\Command\SetLightState::rgb
  *
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidRGBValue($red, $green, $blue)
 {
     $_x = new SetLightState($this->mockLight);
     $_x->rgb($red, $green, $blue);
 }
All Usage Examples Of Phue\Command\SetLightState::rgb