phpvms/app/Support/Http.php
Nabeel S 092b9fc9dc
Add step fields to enable decimal points on fields #342 (#343)
* Add step fields to enable decimal points on fields #342

* Update js-yaml version due to vulnerability scan

* Don't seed dev files when env == local

* Fix

* Fix  to be static

* Add visibilty keyword
2019-08-06 15:54:21 -04:00

40 lines
863 B
PHP

<?php
namespace App\Support;
use GuzzleHttp\Client;
/**
* Helper for HTTP stuff
*/
class Http
{
/**
* Download a URI. If a file is given, it will save the downloaded
* content into that file
*
* @param $uri
* @param array $opts
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string
*/
public static function get($uri, array $opts)
{
$opts = array_merge([
'connect_timeout' => 2, // wait two seconds by default
], $opts);
$client = new Client();
$responseSeederService = $client->request('GET', $uri, $opts);
$body = $response->getBody()->getContents();
if ($response->getHeader('content-type') === 'application/json') {
$body = \GuzzleHttp\json_decode($body);
}
return $body;
}
}