More test coverage.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user