Static analysis cleanup.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-06-13 08:15:29 +00:00
parent 0f3bbf1f47
commit 4ffac17b62
6 changed files with 47 additions and 22 deletions

View File

@ -2,24 +2,44 @@
namespace App\Notification;
use App\Notification\Ntfy;
class Notification
{
/**
* @type NotificationInterface[] $notifiers
* @var NotificationInterface[] $notifiers
*/
public array $notifiers = array();
/**
* Load multiple configurations
*
* @param array<array<string>> $config Array of notifier configurations.
*/
public function loadMany(array $config): void
{
foreach ($config as $key => $conf) {
$this->loadSingle($key, $conf);
foreach ($config as $conf) {
$this->loadSingle($conf['type'], $conf);
}
}
/**
* Load a single configuration
*
* @param string $key Notification class
* @param string[] $config Implementation specific configuration
*/
public function loadSingle(string $key, array $config): void
{
$class = "\App\Notification\\" . $key;
$this->notifiers[$key] = new $class($config);
switch ($key) {
case 'ntfy':
case 'Ntfy':
case 'NTFY':
$this->notifiers[] = new Ntfy($config);
break;
default:
break;
}
}
public function send(string $title, string $message): void