<?php
declare(strict_types=1);

namespace Autogedal\Reduceri\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractHelper
{
    private const XML_ENABLED              = 'autogedal_reduceri/general/enabled';
    private const XML_BANNER_ENABLED       = 'autogedal_reduceri/general/banner_enabled';
    private const XML_BANNER_IMAGE         = 'autogedal_reduceri/general/banner_image';
    private const XML_BANNER_IMAGE_MOBILE  = 'autogedal_reduceri/general/banner_image_mobile';
    private const XML_EXCLUDED_CATEGORIES  = 'autogedal_reduceri/general/excluded_categories';

    public function isEnabled(): bool
    {
        return $this->scopeConfig->isSetFlag(self::XML_ENABLED, ScopeInterface::SCOPE_STORE);
    }

    public function isBannerEnabled(): bool
    {
        return $this->scopeConfig->isSetFlag(self::XML_BANNER_ENABLED, ScopeInterface::SCOPE_STORE);
    }

    public function getBannerImage(): string
    {
        return (string) $this->scopeConfig->getValue(self::XML_BANNER_IMAGE, ScopeInterface::SCOPE_STORE);
    }

    public function getBannerImageMobile(): string
    {
        return (string) $this->scopeConfig->getValue(self::XML_BANNER_IMAGE_MOBILE, ScopeInterface::SCOPE_STORE);
    }

    public function getExcludedCategoryIds(): array
    {
        $value = $this->scopeConfig->getValue(self::XML_EXCLUDED_CATEGORIES, ScopeInterface::SCOPE_STORE);
        if (empty($value)) {
            return [];
        }
        return array_filter(array_map('intval', explode(',', $value)));
    }
}
