Laravel 9 Update (#1413)

Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
This commit is contained in:
Nabeel S
2022-03-14 11:45:18 -04:00
committed by GitHub
parent 00bf18c225
commit 12848091a2
340 changed files with 6130 additions and 4502 deletions

View File

@@ -10,7 +10,7 @@ use GuzzleHttp\RequestOptions;
*/
class HttpClient
{
private $httpClient;
private GuzzleClient $httpClient;
public function __construct(GuzzleClient $httpClient)
{
@@ -50,9 +50,11 @@ class HttpClient
* @param $body
* @param array $opts
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return mixed
*/
public function post($uri, $body, array $opts = [])
public function post($uri, $body, array $opts = []): mixed
{
$opts = array_merge([
'connect_timeout' => 2,
@@ -61,11 +63,40 @@ class HttpClient
$response = $this->httpClient->post($uri, $opts);
$content_type = $response->getHeaderLine('content-type');
if (strpos($content_type, 'application/json') !== false) {
$body = \GuzzleHttp\json_decode($body, true);
$content = $response->getBody()->getContents();
if (str_contains($content_type, 'application/json') !== false) {
$content = \GuzzleHttp\json_decode($content, true);
}
return $body;
return $content;
}
/**
* @param $uri
* @param $body
* @param array $opts
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return mixed
*/
public function form_post($uri, $body, array $opts = []): mixed
{
$opts = array_merge([
'connect_timeout' => 2,
'form_params' => $body,
], $opts);
$response = $this->httpClient->request('POST', $uri, $opts);
$content_type = $response->getHeaderLine('content-type');
$content = $response->getBody()->getContents();
if (str_contains($content_type, 'application/json') !== false) {
$content = \GuzzleHttp\json_decode($content, true);
}
return $content;
}
/**