Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix php versions #4

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@ class AbstractEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* The event instance.
*/
public array $content;

/**
* The event instance.
*/
public HeaderBag $headers;

/**
* Create a new event instance.
*/
public function __construct(
public array $content,
public HeaderBag $headers
) {}
array $content,
HeaderBag $headers
) {
$this->content = $content;
$this->headers = $headers;
}

/**
* Get the event type
Expand All @@ -34,8 +50,6 @@ public function content(): array

/**
* Get the event type
*
* @return HeaderBag
*/
public function headers(): HeaderBag
{
Expand Down
4 changes: 1 addition & 3 deletions src/EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public function content(): array;

/**
* Get the event type
*
* @return HeaderBag
*/
public function headers(): HeaderBag;

Expand All @@ -29,4 +27,4 @@ public function headers(): HeaderBag;
* @return string
*/
public function __get($name);
}
}
2 changes: 1 addition & 1 deletion src/GithookServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GithookServiceProvider extends ServiceProvider
/**
* Bootstrap the application services.
*/
public function boot()
public function boot(): void
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'githook');
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
Expand Down
18 changes: 12 additions & 6 deletions src/Notifications/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

namespace Digitlimit\Githook\Notifications;

use Digitlimit\Githook\EventInterface;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Digitlimit\Githook\EventInterface;

class Email extends Notification implements ShouldQueue
{
use Queueable;

/**
* The event instance.
*/
public EventInterface $event;

/**
* Create a new notification instance.
*/
public function __construct(
public EventInterface $event
){
EventInterface $event
) {
$this->event = $event;
}

/**
Expand All @@ -36,8 +42,8 @@ public function via(object $notifiable): array
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line('Webhook event received: ' . $this->event->event())
->line('Content: ' . json_encode($this->event->content()));
->line('Webhook event received: '.$this->event->event())
->line('Content: '.json_encode($this->event->content()));
}

/**
Expand All @@ -49,7 +55,7 @@ public function toArray(object $notifiable): array
{
return [
'event' => $this->event->event(),
'content' => $this->event->content()
'content' => $this->event->content(),
];
}
}
16 changes: 11 additions & 5 deletions src/Notifications/Slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ class Slack extends Notification implements ShouldQueue
{
use Queueable;

/**
* The event instance.
*/
public EventInterface $event;

/**
* Create a new notification instance.
*/
public function __construct(
public EventInterface $event
){
EventInterface $event
) {
$this->event = $event;
}

/**
Expand All @@ -37,10 +43,10 @@ public function via(object $notifiable): array
public function toSlack(object $notifiable): SlackMessage
{
return (new SlackMessage)
->text('Webhook event received: ' . $this->event->event())
->text('Webhook event received: '.$this->event->event())
->headerBlock('Webhook Event Received')
->contextBlock(function (ContextBlock $block) {
$block->text('Content: ' . json_encode($this->event->content()));
$block->text('Content: '.json_encode($this->event->content()));
});
}

Expand All @@ -53,7 +59,7 @@ public function toArray(object $notifiable): array
{
return [
'event' => $this->event->event(),
'content' => $this->event->content()
'content' => $this->event->content(),
];
}
}
Loading