-
Notifications
You must be signed in to change notification settings - Fork 169
/
StubTransportFactory.php
39 lines (32 loc) · 1.15 KB
/
StubTransportFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Sentry\SentryBundle\Test\End2End;
use Sentry\Event;
use Sentry\Options;
use Sentry\Transport\TransportFactoryInterface;
use Sentry\Transport\TransportInterface;
class StubTransportFactory implements TransportFactoryInterface
{
public const SEPARATOR = '###';
public function create(Options $options): TransportInterface
{
return new class() implements TransportInterface {
public function send(Event $event): ?string
{
touch(End2EndTest::SENT_EVENTS_LOG);
if ($event->getMessage()) {
$message = $event->getMessage();
} elseif ($event->getExceptions()) {
$message = $event->getExceptions()[0]['value'];
} else {
$message = 'NO MESSAGE NOR EXCEPTIONS';
}
file_put_contents(
End2EndTest::SENT_EVENTS_LOG,
$event->getId() . ': ' . $message . PHP_EOL . StubTransportFactory::SEPARATOR . PHP_EOL,
FILE_APPEND
);
return $event->getId();
}
};
}
}