<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace ModulesGarden\HostingQuotaNotifications\App\Helper\SmartyHelper;

use ModulesGarden\HostingQuotaNotifications\App\Helper\DBModelsHelper;

/**
 * Description of Notifications
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class Notification
{

    private $data;
    private $output;

    public function __construct($notificationsData)
    {
        $this->data['notification_limit']                      = $notificationsData['notification_limit'];
        $this->data['notification_usage']                      = $notificationsData['notification_usage'];
        $this->data['notification_kind']                       = $notificationsData['notification_kind'];
        $this->data['notification_unit']                       = $notificationsData['notification_unit'];
        $this->data['notification_difference_usage_and_limit'] = $notificationsData['notification_differenceUsageAndLimit'];
        $this->data['notification_period_days']                = $notificationsData['notification_periodDays'];
        $this->data['service_bandwidth_limit']                 = $notificationsData['service_bwLimit'];
        $this->data['service_disk_limit']                      = $notificationsData['service_diskLimit'];
    }

    public function getFormatedData()
    {
        $this->output = $this->data;

        return $this->output;
    }

    public function getMergeFields()
    {
        $map      = self::getMergeFieldsMap();
        $formated = $this->getFormatedData();
        $fields   = [];

        foreach ($map as $k => $v)
        {
            $fields[$k] = $formated[$v];
        }

        return $fields;
    }

    public static function getMergeFieldsNames()
    {
        return array_keys(self::getMergeFieldsMap());
    }

    private static function getMergeFieldsMap()
    {
        return [
            'notification_limit'                      => 'notification_limit',
            'notification_usage'                      => 'notification_usage',
            'notification_kind'                       => 'notification_kind',
            'notification_unit'                       => 'notification_unit',
            'notification_difference_usage_and_limit' => 'notification_difference_usage_and_limit',
            'notification_period_days'                => 'notification_period_days',
            'service_bandwidth_limit'                 => 'service_bandwidth_limit',
            'service_disk_limit'                      => 'service_disk_limit',
        ];
    }
}
