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

Generate and return a token.
public generateToken ( string $source, string $target, string $text ) : mixed
$source string Source language
$target string Target language
$text string Text to translate
Результат mixed A token
 /**
  * Get response array.
  *
  * @param string|array $data String or array of strings to translate
  *
  * @throws InvalidArgumentException If the provided argument is not of type 'string'
  * @throws ErrorException           If the HTTP request fails
  * @throws UnexpectedValueException If received data cannot be decoded
  *
  * @return array Response
  */
 private function getResponse($data)
 {
     if (!is_string($data) && !is_array($data)) {
         throw new InvalidArgumentException('Invalid argument provided');
     }
     $tokenData = is_array($data) ? implode('', $data) : $data;
     $queryArray = array_merge($this->urlParams, ['sl' => $this->sourceLanguage, 'tl' => $this->targetLanguage, 'tk' => $this->tokenProvider->generateToken($this->sourceLanguage, $this->targetLanguage, $tokenData)]);
     $queryUrl = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', http_build_query($queryArray));
     $queryBodyArray = ['q' => $data];
     $queryBodyEncoded = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', http_build_query($queryBodyArray));
     try {
         $response = $this->httpClient->post($this->urlBase, ['query' => $queryUrl, 'body' => $queryBodyEncoded] + $this->httpOptions);
     } catch (GuzzleRequestException $e) {
         throw new ErrorException($e->getMessage());
     }
     $body = $response->getBody();
     // Get response body
     // Modify body to avoid json errors
     $bodyJson = preg_replace(array_keys($this->resultRegexes), array_values($this->resultRegexes), $body);
     // Decode JSON data
     if (($bodyArray = json_decode($bodyJson, true)) === null) {
         throw new UnexpectedValueException('Data cannot be decoded or it\'s deeper than the recursion limit');
     }
     return $bodyArray;
 }