More tests
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2023-08-14 14:24:19 +00:00
parent 1d94738b04
commit 31891f3e53
4 changed files with 71 additions and 29 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Notification;
use App\Notification\Ntfy;
use Psr\Log\NullLogger;
class Notification
{
@ -13,6 +14,10 @@ class Notification
*/
private array $notifiers = array();
public function __construct(private NullLogger $logger = new NullLogger())
{
}
/**
* Load multiple configurations
*
@ -63,7 +68,11 @@ class Notification
public function send(string $title, string $message): void
{
foreach ($this->getNotifiers() as $notifier) {
$notifier->send($title, $message);
try {
$notifier->send($title, $message);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
}
}
}

View File

@ -6,5 +6,6 @@ namespace App\Notification;
interface NotificationInterface
{
static function factory(array $config): self;
public function send(string $title, string $message): void;
}