Phue\Command\CreateScene::transitionTime PHP Method

transitionTime() public method

Set transition time
public transitionTime ( double $seconds ) : self
$seconds double Time in seconds
return self This object
    public function transitionTime($seconds)
    {
        // Don't continue if seconds is not valid
        if ((double) $seconds < 0) {
            throw new \InvalidArgumentException('Time must be at least 0');
        }
        // Value is in 1/10 seconds
        $this->transitionTime = (int) ($seconds * 10);
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Test: Send command
  *
  * @covers \Phue\Command\CreateScene::__construct
  * @covers \Phue\Command\CreateScene::send
  */
 public function testSend()
 {
     $command = new CreateScene('phue-test', 'Scene test', [2, 3]);
     $command->transitionTime(5);
     // Stub transport's sendRequest usage
     $this->mockTransport->expects($this->once())->method('sendRequest')->with($this->equalTo("/api/{$this->mockClient->getUsername()}/scenes/phue-test"), $this->equalTo(TransportInterface::METHOD_PUT), $this->equalTo((object) ['name' => 'Scene test', 'lights' => [2, 3], 'transitiontime' => 50]));
     // Send command
     $command->send($this->mockClient);
 }