DaitoExceptionNotifier.php
1.23 KB
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 Daito\Lib;
use Daito\Lib\DaitoExceptionNotifier\DaitoExceptionNotifierManager;
use RuntimeException;
use Throwable;
class DaitoExceptionNotifier
{
public static function send(Throwable $throwable, array $arrContext = array(), $webhookUrl = null): array
{
return self::manager()->send($throwable, $arrContext, $webhookUrl);
}
public static function queue(Throwable $throwable, array $arrContext = array(), $webhookUrl = null): void
{
self::manager()->queue($throwable, $arrContext, $webhookUrl);
}
public static function notify(Throwable $throwable, array $arrContext = array(), $webhookUrl = null)
{
return self::manager()->notify($throwable, $arrContext, $webhookUrl);
}
private static function manager(): DaitoExceptionNotifierManager
{
if (!function_exists('app')) {
throw new RuntimeException('Laravel app container is required for DaitoExceptionNotifier.');
}
$manager = app(DaitoExceptionNotifierManager::class);
if (!$manager instanceof DaitoExceptionNotifierManager) {
throw new RuntimeException('Can not resolve DaitoExceptionNotifierManager from container.');
}
return $manager;
}
}