diff --git a/library/Phue/Client.php b/library/Phue/Client.php index e663a58..b5b525b 100644 --- a/library/Phue/Client.php +++ b/library/Phue/Client.php @@ -26,7 +26,6 @@ */ class Client { - /** * Host address * @@ -83,7 +82,7 @@ public function getHost() public function setHost($host) { $this->host = (string) $host; - + return $this; } @@ -108,7 +107,7 @@ public function getUsername() public function setUsername($username) { $this->username = (string) $username; - + return $this; } @@ -213,7 +212,7 @@ public function getTransport() if ($this->transport === null) { $this->setTransport(new Http($this)); } - + return $this->transport; } @@ -228,7 +227,7 @@ public function getTransport() public function setTransport(TransportInterface $transport) { $this->transport = $transport; - + return $this; } diff --git a/library/Phue/Helper/ColorConversion.php b/library/Phue/Helper/ColorConversion.php index 6d02a20..4e0dde0 100644 --- a/library/Phue/Helper/ColorConversion.php +++ b/library/Phue/Helper/ColorConversion.php @@ -8,19 +8,18 @@ */ namespace Phue\Helper; - +/** + * Helper for converting colors to and from rgb + */ class ColorConversion { /** * Converts RGB values to XY values * Based on: http://stackoverflow.com/a/22649803 - * - * @param int $red - * Red value - * @param int $green - * Green value - * @param int $blue - * Blue value + * + * @param int $red Red value + * @param int $green Green value + * @param int $blue Blue value * * @return array x, y, bri key/value */ @@ -53,24 +52,21 @@ public static function convertRGBToXY($red, $green, $blue) $x = $xyz['x'] / array_sum($xyz); $y = $xyz['y'] / array_sum($xyz); } - + return array( - 'x' => $x, - 'y' => $y, + 'x' => $x, + 'y' => $y, 'bri' => round($xyz['y'] * 255) ); } /** * Converts XY (and brightness) values to RGB - * - * @param float $x - * X value - * @param float $y - * Y value - * @param int $bri - * Brightness value - * + * + * @param float $x X value + * @param float $y Y value + * @param int $bri Brightness value + * * @return array red, green, blue key/value */ public static function convertXYToRGB($x, $y, $bri = 255) @@ -85,7 +81,7 @@ public static function convertXYToRGB($x, $y, $bri = 255) $color['red'] = $xyz['x'] * 1.656492 - $xyz['y'] * 0.354851 - $xyz['z'] * 0.255038; $color['green'] = -$xyz['x'] * 0.707196 + $xyz['y'] * 1.655397 + $xyz['z'] * 0.036152; $color['blue'] = $xyz['x'] * 0.051713 - $xyz['y'] * 0.121364 + $xyz['z'] * 1.011530; - + foreach ($color as $key => $normalized) { // Apply reverse gamma correction if ($normalized <= 0.0031308) { @@ -93,11 +89,11 @@ public static function convertXYToRGB($x, $y, $bri = 255) } else { $color[$key] = (1.0 + 0.055) * pow($normalized, 1.0 / 2.4) - 0.055; } - + // Scale back from a maximum of 1 to a maximum of 255 $color[$key] = round($color[$key] * 255); } - + return $color; } } diff --git a/library/Phue/Light.php b/library/Phue/Light.php index 209bc3a..9373c3c 100644 --- a/library/Phue/Light.php +++ b/library/Phue/Light.php @@ -18,7 +18,6 @@ */ class Light { - /** * Id * @@ -87,9 +86,9 @@ public function getName() public function setName($name) { $this->client->sendCommand(new Command\SetLightName($this, (string) $name)); - + $this->attributes->name = (string) $name; - + return $this; } @@ -166,9 +165,9 @@ public function setOn($flag = true) $x = new SetLightState($this); $y = $x->on((bool) $flag); $this->client->sendCommand($y); - + $this->attributes->state->on = (bool) $flag; - + return $this; } @@ -195,9 +194,9 @@ public function setAlert($mode = SetLightState::ALERT_LONG_SELECT) $x = new SetLightState($this); $y = $x->alert($mode); $this->client->sendCommand($y); - + $this->attributes->state->alert = $mode; - + return $this; } @@ -224,9 +223,9 @@ public function setEffect($mode = SetLightState::EFFECT_NONE) $x = new SetLightState($this); $y = $x->effect($mode); $this->client->sendCommand($y); - + $this->attributes->state->effect = $mode; - + return $this; } @@ -253,9 +252,9 @@ public function setBrightness($level = SetLightState::BRIGHTNESS_MAX) $x = new SetLightState($this); $y = $x->brightness((int) $level); $this->client->sendCommand($y); - + $this->attributes->state->bri = (int) $level; - + return $this; } @@ -282,11 +281,11 @@ public function setHue($value) $x = new SetLightState($this); $y = $x->hue((int) $value); $this->client->sendCommand($y); - + // Change both hue and color mode state $this->attributes->state->hue = (int) $value; $this->attributes->state->colormode = 'hs'; - + return $this; } @@ -313,11 +312,11 @@ public function setSaturation($value) $x = new SetLightState($this); $y = $x->saturation((int) $value); $this->client->sendCommand($y); - + // Change both saturation and color mode state $this->attributes->state->sat = (int) $value; $this->attributes->state->colormode = 'hs'; - + return $this; } @@ -349,14 +348,14 @@ public function setXY($x, $y) $_x = new SetLightState($this); $_y = $_x->xy((float) $x, (float) $y); $this->client->sendCommand($_y); - + // Change both internal xy and colormode state $this->attributes->state->xy = array( $x, $y ); $this->attributes->state->colormode = 'xy'; - + return $this; } @@ -367,7 +366,7 @@ public function setXY($x, $y) */ public function getRGB() { - $xy = $this->getXY(); + $xy = $this->getXY(); $bri = $this->getBrightness(); $rgb = ColorConversion::convertXYToRGB($xy['x'], $xy['y'], $bri); @@ -376,14 +375,11 @@ public function getRGB() /** * Set XY and brightness calculated from RGB - * - * @param int $red - * Red value - * @param int $green - * Green value - * @param int $blue - * Blue value - * + * + * @param int $red Red value + * @param int $green Green value + * @param int $blue Blue value + * * @return self This object */ public function setRGB($red, $green, $blue) @@ -400,7 +396,7 @@ public function setRGB($red, $green, $blue) ); $this->attributes->state->bri = $xy['bri']; $this->attributes->state->colormode = 'xy'; - + return $this; } @@ -417,8 +413,7 @@ public function getColorTemp() /** * Set Color temperature * - * @param int $value - * Color temperature value + * @param int $value Color temperature value * * @return self This object */ @@ -427,11 +422,11 @@ public function setColorTemp($value) $x = new SetLightState($this); $y = $x->colorTemp((int) $value); $this->client->sendCommand($y); - + // Change both internal color temp and colormode state $this->attributes->state->ct = (int) $value; $this->attributes->state->colormode = 'ct'; - + return $this; } diff --git a/library/Phue/User.php b/library/Phue/User.php index e5e4c87..2f280e0 100644 --- a/library/Phue/User.php +++ b/library/Phue/User.php @@ -15,7 +15,6 @@ */ class User { - /** * Username *