More test coverage.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-07-03 14:28:53 +00:00
parent be2985c797
commit a070849293
2 changed files with 69 additions and 4 deletions

View File

@ -9,7 +9,7 @@ class Notification
/**
* @var NotificationInterface[] $notifiers
*/
public array $notifiers = array();
private array $notifiers = array();
/**
* Load multiple configurations
@ -28,7 +28,7 @@ class Notification
*
* @param string $key Notification class
* @param string[] $config Implementation specific configuration
* @SuppressWarnings(PHPMD)
* @SuppressWarnings(PHPMD)
*/
public function loadSingle(string $key, array $config): void
{
@ -36,16 +36,31 @@ class Notification
case 'ntfy':
case 'Ntfy':
case 'NTFY':
$this->notifiers[] = Ntfy::factory($config);
$this->addNotifier(Ntfy::factory($config));
break;
default:
break;
}
}
public function addNotifier(NotificationInterface $instance): void
{
$this->notifiers[] = $instance;
}
/**
* Get all active notifiers.
*
* @return NotificationInterface[] All notifiers.
*/
public function getNotifiers(): array
{
return $this->notifiers;
}
public function send(string $title, string $message): void
{
foreach ($this->notifiers as $notifier) {
foreach ($this->getNotifiers() as $notifier) {
$notifier->send($title, $message);
}
}