Skip to content

Commit

Permalink
New callable extension added
Browse files Browse the repository at this point in the history
  • Loading branch information
M1ke committed Feb 28, 2024
1 parent 5edb910 commit 54f48a3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Extensions/CallableExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Kodus\Sentry\Extensions;

use Throwable;
use Kodus\Sentry\Model\Event;
use Kodus\Sentry\SentryClientExtension;
use Psr\Http\Message\ServerRequestInterface;

class CallableExtension implements SentryClientExtension
{
/**
* @var Closure(Event, Throwable, ServerRequestInterface|null):void
*/
private $callable;

/**
* @param Closure(Event, Throwable, ServerRequestInterface|null):void $callable
*/
public function __construct(callable $callable) {
$this->callable = $callable;
}

public function apply(Event $event, Throwable $exception, ?ServerRequestInterface $request): void {
$callable = $this->callable;
$callable($event, $exception, $request);
}
}

0 comments on commit 54f48a3

Please sign in to comment.