You are here

public function AvatarKitDownloadUtility::get in Avatar Kit 8.2

Get stream for a file.

Parameters

string $uri: The URL of the file to download.

Return value

\Psr\Http\Message\ResponseInterface The response stream.

Throws

\InvalidArgumentException If the URI is defective.

\Exception Various other exceptions thrown from HTTP client.

Overrides AvatarKitDownloadUtilityInterface::get

File

src/AvatarKitDownloadUtility.php, line 79

Class

AvatarKitDownloadUtility
Utility for creating Drupal files from responses.

Namespace

Drupal\avatars

Code

public function get(string $uri) : ResponseInterface {
  $valid_url = !empty($uri) && parse_url($uri) !== FALSE;
  if (!$valid_url) {
    throw new \InvalidArgumentException('Malformed Url');
  }
  $response = $this->httpClient
    ->get($uri);
  return $response;
}