Static analysis cleanup.
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:
@ -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
|
||||
|
Reference in New Issue
Block a user