-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from TahsinGokalp/development
Merge development to master
- Loading branch information
Showing
13 changed files
with
105 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
0b3432d95fa080f1ceda922d0b95bd7a3cdcf0ee | ||
2c9660debe53324156654726ddecf5bb04137c51 | ||
0b4771d854aa254e7e618e02e82d8f909aa3a003 | ||
3bd1a83d82ecd2ba335c084e85a837aa81bdf5ab | ||
66cd5bd2cfb3463dfd7da224a15b043d0173a10e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ includes: | |
- phpstan-baseline.neon | ||
|
||
parameters: | ||
level: 5 | ||
level: 6 | ||
paths: | ||
- src | ||
- config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace TahsinGokalp\Lett; | ||
|
||
use Exception; | ||
use GuzzleHttp\ClientInterface; | ||
use GuzzleHttp\Exception\GuzzleException; | ||
use GuzzleHttp\Exception\RequestException; | ||
use GuzzleHttp\Promise\PromiseInterface; | ||
use Illuminate\Http\Client\PendingRequest; | ||
use Illuminate\Support\Facades\Http; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class Client | ||
{ | ||
protected PendingRequest|ClientInterface $client; | ||
|
||
protected string $login; | ||
|
||
protected string $project; | ||
|
||
private int $timeout; | ||
|
||
public function __construct(string $login, string $project, PendingRequest|ClientInterface $client = null) | ||
{ | ||
$this->login = $login; | ||
$this->project = $project; | ||
$this->timeout = config('lett.timeout'); | ||
$this->client = $client ?: Http::timeout($this->timeout); | ||
} | ||
|
||
public function report(array $exception): PromiseInterface|ResponseInterface|null | ||
{ | ||
try { | ||
return $this->getHttpClient() | ||
->withToken($this->login) | ||
->asJson() | ||
->acceptJson() | ||
->withUserAgent('Lett-Package') | ||
->when( | ||
! config('lett.verify_ssl'), | ||
function ($client) { | ||
$client->withoutVerifying(); | ||
} | ||
) | ||
->post( | ||
config('lett.server'), | ||
array_merge( | ||
[ | ||
'project' => $this->project, | ||
'additional' => [], | ||
], | ||
$exception | ||
) | ||
)->toPsrResponse(); | ||
} catch (RequestException $e) { | ||
return $e->getResponse(); | ||
} catch (GuzzleException|Exception) { | ||
return null; | ||
} | ||
} | ||
|
||
public function getHttpClient(): PendingRequest|ClientInterface | ||
{ | ||
return $this->client; | ||
} | ||
|
||
public function setHttpClient(\GuzzleHttp\Client $client): self | ||
{ | ||
$this->client = Http::timeout($this->timeout)->setClient($client)->buildClient(); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.