Skip to content

Commit

Permalink
Merge pull request #2 from Tahaknd/main
Browse files Browse the repository at this point in the history
add PHPDoc and hints
  • Loading branch information
emredipi authored Feb 24, 2024
2 parents b1cbbb7 + 1b23d8d commit 643ee3e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/Providers/DefaultProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Moneo\RequestForwarder\Providers;

use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Http\Client\Factory;
use Illuminate\Http\Client\Response;

class DefaultProvider implements ProviderInterface
{
Expand All @@ -11,7 +13,10 @@ public function __construct(
) {
}

public function send($url, $params, $webhook)
/**
* @throws \Exception
*/
public function send(string $url, array $params, array $webhook): Response
{
return $this->client
->send($webhook['method'] ?? 'POST', $webhook['url']);
Expand Down
6 changes: 5 additions & 1 deletion src/Providers/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Moneo\RequestForwarder\Providers;

use Illuminate\Http\Client\Factory;
use Illuminate\Http\Client\Response;

class Discord implements ProviderInterface
{
Expand All @@ -11,7 +12,10 @@ public function __construct(
) {
}

public function send($url, $params, $webhook)
/**
* @throws \Exception
*/
public function send(string $url, array $params, array $webhook): Response
{
$content = $url.PHP_EOL;
$content .= json_encode($params);
Expand Down
4 changes: 2 additions & 2 deletions src/Providers/ProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Moneo\RequestForwarder\Providers;

use Illuminate\Http\Client\Factory;
use Illuminate\Http\Client\Response;

interface ProviderInterface
{
public function __construct(Factory $client);

/** @return \Illuminate\Http\Client\Response */
public function send($url, $params, $webhook);
public function send(string $url, array $params, array $webhook): Response;
}
4 changes: 2 additions & 2 deletions src/RequestForwarder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public function __construct(
) {
}

public function sendAsync(Request $request)
public function sendAsync(Request $request): void
{
ProcessRequestForwarder::dispatch($request->url(), $request->toArray());
}

public function triggerHooks(string $url, array $params)
public function triggerHooks(string $url, array $params): void
{
foreach ($this->webhooks as $webhook) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/RequestForwarderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function configurePackage(Package $package): void
->hasConfigFile();
}

public function registeringPackage()
public function registeringPackage(): void
{
$this->app->bind('laravel_request_forwarder.client', function ($app): Factory {
return $app[Factory::class];
Expand Down

0 comments on commit 643ee3e

Please sign in to comment.