<?php

namespace GriffinForms\Admin\Secure;

class Compliance extends \GriffinForms\Admin\Secure\Settings
{
    protected function secureComplianceDefaultProfile($value): string
    {
        $val = is_string($value) ? sanitize_text_field($value) : '';
        $allowed = $this->choices->getChoices('compliance_default_profile', false);
        if (!in_array($val, $allowed, true)) {
            $val = 'standard';
        }
        return $val;
    }

    protected function secureComplianceDefaultsEnabled($value): int
    {
        return !empty($value) ? 1 : 0;
    }

    protected function secureComplianceDefaultStoreIp($value): int
    {
        return !empty($value) ? 1 : 0;
    }

    protected function secureComplianceDefaultStoreUserAgent($value): int
    {
        return !empty($value) ? 1 : 0;
    }

    protected function secureComplianceDefaultRetentionDays($value): int
    {
        if ($value === '' || $value === null) {
            return 0;
        }
        return max(0, absint($value));
    }

    protected function secureComplianceTrustProxyHeaders($value): int
    {
        return !empty($value) ? 1 : 0;
    }

    protected function secureComplianceShowIpNotice($value): int
    {
        return !empty($value) ? 1 : 0;
    }
}
