HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: //proc/self/cwd/wp-content/plugins/luman-plus/Includes/App/Notification/NotificationService.php
<?php


namespace lumanPlus\App\Notification;

use lumanPlus\App\Notification\Core\NotificationManager;
use lumanPlus\App\Notification\Traits\{HasNotification, HasPattern};
use lumanPlus\Core\Helper;
use lumanPlus\Core\Logger;

class NotificationService {

    use HasNotification, HasPattern;

    private $driver = null;
    private $service = null;
    private $to = null;

    public function setDriver(string $driver): NotificationService
    {
        $this->driver = $driver;
        return $this;
    }

    public function setService(string $service): NotificationService
    {
        $this->service = $service;
        return $this;
    }

    public function setRecipient (string $to): NotificationService
    {
        $this->to = $to;
        return $this;
    }

    public function sendWithPattern(string $pattern, array $attributes): bool
    {
        $driver = $this->driver ?? $this->getDefaultDriver();
        $service = $this->service ?? $this->getDefaultService();

        $patternCode = $this->checkPattern($pattern,$service);

        if ( empty($patternCode) ) {
            Logger::warning('Pattern not set for service',[
                'service'   => $service,
                'pattern'   => $pattern,
                'driver'    => $driver
            ]);
            return false;
        }

        $manager = new NotificationManager($driver, $service);

        $driverInstance = $manager->getDriver();
        return $driverInstance->sendWithPattern($patternCode,$attributes,$this->to);

    }

    private function getDefaultDriver(): string {
        
        return Helper::getOption('default_driver');
    }

    private function getDefaultService(): string {
        return Helper::getOption('default_service');
    }
}