Phue\Command\IsAuthorized::send PHP Method

send() public method

Send command
public send ( Client $client ) : boolean
$client Phue\Client Phue Client
return boolean True if authorized, false if not
    public function send(Client $client)
    {
        // Get response
        try {
            $client->getTransport()->sendRequest("/api/{$client->getUsername()}");
        } catch (UnauthorizedUserException $e) {
            return false;
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * Test: Is not authorized
  *
  * @covers \Phue\Command\IsAuthorized::send
  */
 public function testIsNotAuthorized()
 {
     // Stub transport's sendRequest
     $this->mockTransport->expects($this->once())->method('sendRequest')->with($this->equalTo("/api/{$this->mockClient->getUsername()}"))->will($this->throwException($this->getMock('\\Phue\\Transport\\Exception\\UnauthorizedUserException')));
     $auth = new IsAuthorized();
     $this->assertFalse($auth->send($this->mockClient));
 }
IsAuthorized