Stichoza\GoogleTranslate\TranslateClient::__construct PHP Метод

__construct() публичный Метод

For more information about HTTP client configuration options, visit "Creating a client" section of GuzzleHttp docs. 5.x - http://guzzle.readthedocs.org/en/5.3/clients.html#creating-a-client
public __construct ( string $source = null, string $target = 'en', array $options = [], Stichoza\GoogleTranslate\Tokens\TokenProviderInterface $tokener = null )
$source string Source language (Optional)
$target string Target language (Optional)
$options array Associative array of http client configuration options (Optional)
$tokener Stichoza\GoogleTranslate\Tokens\TokenProviderInterface
    public function __construct($source = null, $target = 'en', $options = [], TokenProviderInterface $tokener = null)
    {
        $this->httpClient = new GuzzleHttpClient($options);
        // Create HTTP client
        $this->setSource($source)->setTarget($target);
        // Set languages
        $this::$lastDetectedSource = false;
        if (!isset($tokener)) {
            $tokener = $this->defaultTokenProvider;
        }
        $tokenProviderReflection = new ReflectionClass($tokener);
        if ($tokenProviderReflection->implementsInterface(TokenProviderInterface::class)) {
            $this->tokenProvider = $tokenProviderReflection->newInstance();
        } else {
            throw new Exception('Token provider should implement TokenProviderInterface');
        }
    }