PHP Class Stevebauman\Translation\Clients\GoogleTranslateApi

Inheritance: implements Stevebauman\Translation\Contracts\Client
Mostra file Open project: stevebauman/translation

Protected Properties

Property Type Description
$client GuzzleHttp\ClientInterface
$config Holds the current config instance.
$endpoint API endpoint
$source source language
$target target language

Public Methods

Method Description
__construct ( Illuminate\Contracts\Foundation\Application $app, GuzzleHttp\ClientInterface $client )
setSource ( $source = null )
setTarget ( $target )
translate ( $text ) : string

Protected Methods

Method Description
getApiKey ( ) : string Returns the api key from the configuration.
getSource ( ) : string Returns the source language.
getTarget ( ) : string Returns the target language.
parseResponse ( array $contents ) : mixed Extract and decode the translation response.

Method Details

__construct() public method

public __construct ( Illuminate\Contracts\Foundation\Application $app, GuzzleHttp\ClientInterface $client )
$app Illuminate\Contracts\Foundation\Application
$client GuzzleHttp\ClientInterface

getApiKey() protected method

Returns the api key from the configuration.
protected getApiKey ( ) : string
return string

getSource() protected method

Returns the source language.
protected getSource ( ) : string
return string

getTarget() protected method

Returns the target language.
protected getTarget ( ) : string
return string

parseResponse() protected method

Extract and decode the translation response.
protected parseResponse ( array $contents ) : mixed
$contents array
return mixed

setSource() public method

public setSource ( $source = null )

setTarget() public method

public setTarget ( $target )

translate() public method

public translate ( $text ) : string
$text
return string

Property Details

$client protected_oe property

protected ClientInterface,GuzzleHttp $client
return GuzzleHttp\ClientInterface

$config protected_oe property

Holds the current config instance.
protected $config

$endpoint protected_oe property

API endpoint
protected $endpoint

$source protected_oe property

source language
protected $source

$target protected_oe property

target language
protected $target