Phue\Command\GetLightById::send PHP Method

send() public method

Send command
public send ( Client $client ) : Light
$client Phue\Client Phue Client
return Phue\Light Light object
    public function send(Client $client)
    {
        // Get response
        $attributes = $client->getTransport()->sendRequest("/api/{$client->getUsername()}/lights/{$this->lightId}");
        return new Light($this->lightId, $attributes, $client);
    }

Usage Example

Example #1
0
 /**
  * Test: Send get light by id command
  *
  * @covers \Phue\Command\GetLightById::__construct
  * @covers \Phue\Command\GetLightById::send
  */
 public function testSend()
 {
     // Stub transport's sendRequest usage
     $this->mockTransport->expects($this->once())->method('sendRequest')->with("/api/{$this->mockClient->getUsername()}/lights/10")->will($this->returnValue(new \stdClass()));
     // Get light
     $x = new GetLightById(10);
     $light = $x->send($this->mockClient);
     // Ensure type is correct
     $this->assertInstanceOf('\\Phue\\Light', $light);
 }