<?php

namespace MGModule\DNSManager2\mgLibs\custom\dns\record\type;

use MGModule\DNSManager2\mgLibs\custom\dns\dnssec\Algorithms;

/**
 * rfc4034
 */
class RRSIG extends RecordTypeAbstract 
{
    public $type;
    public $algorithm;
    public $labels;
    public $ttl;
    public $signatureexpiration;
    public $signatureinception;
    public $keytag;
    public $signer;
    public $signature;
    /**
     * @param string|int $algorithm hard to validate it has to be number 1-3 or 5-10 or one of mnemonic names
     * @return bool
     */
    public function algorithmValidate($algorithm){
        if(is_numeric(trim($algorithm))){
            return ((int)$algorithm >=3 && (int)$algorithm <= 10 && $algorithm!=4);
        }else{
            return in_array(strtoupper($algorithm), Algorithms::$algorithms);
        }
    }

    /**
     * @param int $labels number of labels has to be number
     * @return bool
     */
    public function labelsValidate($labels){
        return is_numeric(trim($labels));
    }
    /**
     * @param int $ttl valid number
     * @return bool
     */
    public function ttlValidate($ttl){
        return is_numeric(trim($ttl));
    }
    /**
     * @param int $signatureexpiration valid number
     * @return bool
     */
    public function signatureexpirationValidate($signatureexpiration){
        return is_numeric(trim($signatureexpiration));
    }
    /**
     * @param int $signatureinception valid number
     * @return bool
     */
    public function signatureinceptionValidate($signatureinception){
        return is_numeric(trim($signatureinception));
    }
    function getType() {
        return $this->type;
    }

    function getAlgorithm() {
        return $this->algorithm;
    }

    function getLabels() {
        return $this->labels;
    }

    function getTtl() {
        return $this->ttl;
    }

    function getSignatureExpiration() {
        return $this->signatureexpiration;
    }

    function getSignatureInception() {
        return $this->signatureinception;
    }

    function getKeyTag() {
        return $this->keytag;
    }

    function getSigner() {
        return $this->signer;
    }

    function getSignature() {
        return $this->signature;
    }

    function setType($type) {
        $this->type = $type;
    }

    function setAlgorithm($algorithm) {
        $this->algorithm = $algorithm;
    }

    function setLabels($labels) {
        $this->labels = $labels;
    }

    function setTtl($ttl) {
        $this->ttl = $ttl;
    }

    function setSignatureExpiration($signatureExpiration) {
        $this->signatureexpiration = $signatureExpiration;
    }

    function setSignatureInception($signatureInception) {
        $this->signatureinception = $signatureInception;
    }

    function setKeyTag($keyTag) {
        $this->keytag = $keyTag;
    }

    function setSigner($signer) {
        $this->signer = $signer;
    }

    function setSignature($signature) {
        $this->signature = $signature;
    }
}