Stevebauman\Translation\Contracts\Client::translate PHP Method

translate() public method

Translate the text.
public translate ( string $text ) : mixed
$text string
return mixed
    public function translate($text);

Usage Example

 public function testErrorInResponseThrowsException()
 {
     $text = 'Hello, World!';
     $response = m::mock(ResponseInterface::class);
     $this->guzzle->shouldReceive('request')->once()->with('GET', 'https://www.googleapis.com/language/translate/v2', ['query' => ['key' => config('translation.clients.api_key'), 'format' => 'html', 'source' => 'en', 'target' => 'es', 'q' => $text]])->andReturn($response);
     $response->shouldReceive('getBody')->andReturn(json_encode(['error' => 'foo']));
     $this->client->setSource('en');
     $this->client->setTarget('es');
     $this->setExpectedException(\ErrorException::class);
     $this->client->translate($text);
 }
All Usage Examples Of Stevebauman\Translation\Contracts\Client::translate