Skip to content

Commit

Permalink
return types
Browse files Browse the repository at this point in the history
  • Loading branch information
viezel committed Oct 20, 2020
1 parent 02f6e41 commit eabcdf0
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/Controllers/API/CreateWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use Viezel\Webhooks\Models\Webhook;
Expand All @@ -17,7 +18,7 @@ class CreateWebhook extends Controller
use DispatchesJobs;
use ValidatesRequests;

public function __invoke(CreateWebhookRequest $request)
public function __invoke(CreateWebhookRequest $request): JsonResponse
{
$hook = Webhook::create($request->validated());

Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/API/DeleteWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use Viezel\Webhooks\Models\Webhook;
Expand All @@ -16,7 +17,7 @@ class DeleteWebhook extends Controller
use DispatchesJobs;
use ValidatesRequests;

public function __invoke(string $id)
public function __invoke(string $id): JsonResponse
{
Webhook::findOrFail($id)->delete();

Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/API/ListWebhookEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use Viezel\Webhooks\WebhookRegistry;
Expand All @@ -16,7 +17,7 @@ class ListWebhookEvents extends Controller
use DispatchesJobs;
use ValidatesRequests;

public function __invoke()
public function __invoke(): JsonResponse
{
return Response::json(WebhookRegistry::allEvents());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/WebhookCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(Webhook $webhook, array $payload)
$this->payload = $payload;
}

public function handle()
public function handle(): void
{
Http::timeout(10)
//->retry(3, 60)
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/WebhookListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class WebhookListener
{
public function handle(ShouldDeliverWebhooks $event)
public function handle(ShouldDeliverWebhooks $event): void
{
Webhook::trigger($event->getWebhookName(), $event->getWebhookPayload());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Requests/CreateWebhookRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

class CreateWebhookRequest extends FormRequest
{
public function authorize()
public function authorize(): bool
{
return true;
}

public function rules()
public function rules(): array
{
return [
'events' => ['required', 'array'],
Expand Down
8 changes: 4 additions & 4 deletions src/Support/GeneratesIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

trait GeneratesIds
{
public static function bootGeneratesIds()
public static function bootGeneratesIds(): void
{
static::creating(function (self $model) {
if (! $model->getKey()) {
Expand All @@ -16,17 +16,17 @@ public static function bootGeneratesIds()
});
}

public function getIncrementing()
public function getIncrementing(): bool
{
return false;
}

public function getKeyType()
public function getKeyType(): string
{
return 'string';
}

public function getIdAttribute($value)
public function getIdAttribute($value): string
{
return (string) $value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebhooksServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class WebhooksServiceProvider extends ServiceProvider
{
public function boot()
public function boot(): void
{
if ($this->app->runningInConsole()) {
$migrationFileName = 'create_webhooks_table.php';
Expand Down

0 comments on commit eabcdf0

Please sign in to comment.