<?php

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

class TLSA extends RecordTypeAbstract {
    public $certusage;
    public $selector;
    public $matchingtype;
    public $certdata;

    /**
     * @param int $certusage valid number 0-255
     * @return bool
     */
    public function certusageValidate($certusage)
    {
        return (is_numeric(trim($certusage)) && (int)$certusage >= 0 && (int)$certusage <= 255);
    }
    /**
     * @param int $selector valid number 0-255
     * @return bool
     */
    public function selectorValidate($selector)
    {
        return (is_numeric(trim($selector)) && (int)$selector >= 0 && (int)$selector <= 255);
    }
    /**
     * @param int $matchingtype valid number 0-255
     * @return bool
     */
    public function matchingtypeValidate($matchingtype)
    {
        return (is_numeric(trim($matchingtype)) && (int)$matchingtype >= 0 && (int)$matchingtype <= 255);
    }
    /**
     * @param string $certdata valid hexadecimal string
     * @return bool
     */
    public function certdataValidate($certdata){
        return (bool)preg_match('/^[0-9A-F]+$/', $certdata);
    }
    public function __construct($certusage = 0, $selector = 0, $matchingtype = 0, $certdata = '')
    {
        $this->setCertUsage($certusage);
        $this->setSelector($selector);
        $this->setMatchingType($matchingtype);
        $this->setCertData($certdata);
    }
    
    function getCertUsage() {
        return $this->certusage;
    }

    function getSelector() {
        return $this->selector;
    }
    
    function getMatchingType() {
        return $this->matchingtype;
    }
    
    function getCertData() {
        return $this->certdata;
    }

    function setCertUsage($certusage) {
        $this->certusage = $certusage;
    }

    function setSelector($selector) {
        $this->selector = $selector;
    }
    
    function setMatchingType($matchingtype) {
        $this->matchingtype = $matchingtype;
    }
    
    function setCertData($certdata) {
        $this->certdata = $certdata;
    }

}